JavaScript alert not working in Android WebView JavaScript alert not working in Android WebView android android

JavaScript alert not working in Android WebView


As others indicated, setting the WebChromeClient is needed to get alert() to work. It's sufficient to just set the default WebChromeClient():

mWebView.getSettings().setJavaScriptEnabled(true);mWebView.setWebChromeClient(new WebChromeClient());

Thanks for all the comments below. Including John Smith's who indicated that you needed to enable JavaScript.


Check this link , and last comment , You have to use WebChromeClient for your purpose.


webView.setWebChromeClient(new WebChromeClient() {    @Override    public boolean onJsAlert(WebView view, String url, String message, JsResult result) {        return super.onJsAlert(view, url, message, result);    }});