Kishan Dhamat
Kishan Dhamat

Reputation: 3784

PopUp screen not opening In webview?

I am Currently working with webview in which Javascript popup is created when some button is clicked in webview. But it is not opening in my Webview.

My code is Here:

wvPayements = (WebView) view.findViewById(R.id.wvPaymentsPage);
    wvPayements.getSettings().setLoadWithOverviewMode(true);
    wvPayements.getSettings().setUseWideViewPort(true);
    wvPayements.getSettings().setSupportZoom(true);
    wvPayements.getSettings().setAllowFileAccess(true);
    wvPayements.getSettings().setJavaScriptEnabled(true);
    wvPayements.getSettings()
            .setJavaScriptCanOpenWindowsAutomatically(true);
    wvPayements.getSettings().setBuiltInZoomControls(true);
    wvPayements.setWebViewClient(new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, final String url) {
            dialog.cancel();
        }
    });
     wvPayements
     .loadUrl("http://192.168.0.114/Parch_ws/testalert.html");

Upvotes: 3

Views: 14986

Answers (2)

Hardik
Hardik

Reputation: 17441

You have to use WebChromeClient for your purpose:

One should use a WebChromeClient to get these alerts and the functionality can be overwritten using theonJsAlert() method. Hope this helps!

WebView wv=new WebView(this); 
wv.setWebChromeClient(new WebChromeClient() {
    @Override
    public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
        //Required functionality here
        return super.onJsAlert(view, url, message, result);
    }
});

Source: https://issuetracker.google.com/issues/36905249#comment11

Upvotes: 9

Ritesh Chandnani
Ritesh Chandnani

Reputation: 475

This can also happen if you are executing ES6 on unsupported browsers.

You can always check supported versions here

Upvotes: 0

Related Questions