JavaScript alert not working in Android WebView
Solution 1:
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.
Solution 2:
Check this link , and last comment , You have to use WebChromeClient
for your purpose.
Solution 3:
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
return super.onJsAlert(view, url, message, result);
}
});