I’m displaying a webpage in a WebView and on the webpage, there is a button. When you click the button, a confirmation dialog is supposed to popup, but it doesn’t show in my WebView. It does popup if I go to the same webpage in the android browser. Anyone know how to handle popup dialogs coming from a webpage inside your WebView?
Share
Ok, found the answer and here it is!
In order to handle a popup confirmation coming from a webpage in your WebView, you need to override the onJsConfirm method in WebChromeClient to display the popup as an Android Alert dialog. Here is the code to do so.
Don’t forget to set your WebChromeClient in your WebView…
Note.. this isn’t my code, but I found it and it works perfectly for handling javascript confirmation dialogs in a WebView!
Cheers!