2013-01-24 55 views
0

我正在爲我的網站開發應用程序。我的問題是webview。我正確地瀏覽了我的webview,但它在我的Note 2設備中打開了一個彈出式瀏覽器。我不會那樣做,請幫助我。禁用彈出瀏覽器webview

感謝幫助

回答

3

嘗試這些方法可以幫助

WebSettings settings = webview.getSettings(); 
settings.setSupportMultipleWindows(false); 

,並創建一個WebChromeClient低於

final Context mContext = this; 
final class CustomWebChromeClient extends WebChromeClient { 
@Override 
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { 
    new AlertDialog.Builder(mContext) 
    .setTitle("App Titler") 
    .setMessage(message) 
    .setPositiveButton(android.R.string.ok, 
      new DialogInterface.OnClickListener() 
    { 
     public void onClick(DialogInterface dialog, int which) 
     { 
      result.confirm(); 
     } 
    }) 
    .setNegativeButton(android.R.string.cancel, 
      new DialogInterface.OnClickListener() 
    { 
     public void onClick(DialogInterface dialog, int which) 
     { 
      result.cancel(); 
     } 
    }) 
    .create() 
    .show(); 

    return true; 
} 
} 

給出並將其設置爲網頁視圖作爲

webview.setWebChromeClient(new MyWebChromeClient()); 
+0

請你詳細解釋一下JsConfirm(..)函數和代碼內? – Jaydev

0

你可以在加載時檢查您的網站是否是來自設備或計算機打開。如果設備不打開那個彈出窗口,否則什麼也不做。

+0

我不知道哪裏是錯誤但我下載了另一個項目,正在運行問題finn thnx試圖幫助:) –