WebView blocking pop up windows?

蓝咒 提交于 2019-11-30 16:28:38

If i am getting right , you need to use JavaScriptInterface for calling JavaScript function from Android.

Check this link which may help you :

http://www.codeproject.com/Articles/392603/Android-addJavaScriptInterface

Or check some websettings : http://developer.android.com/reference/android/webkit/WebSettings.html#setSupportMultipleWindows%28boolean

try to put this code in onCreate()

        webView.getSettings().setPluginsEnabled(true);
        webView.getSettings().setAllowFileAccess(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);

The function which is responsible for dialogs in Webview is onJsAlert of WebChromeClient.

Here is sample code

  public class MyWebChromeClient extends WebChromeClient {
    @Override
    public boolean onJsAlert(WebView view, String url, String message, JsResult jsResult) {
        // you can create your own dialog here or just return true for no pop up. 
        return true;
    }
}

and add this to your webview:

MyWebChromeClient myWebChromeClient = new MyWebChromeClient();
webView.setWebChromeClient(myWebChromeClient);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!