Skip to content Skip to sidebar Skip to footer

Intercept Html Button Click

is there any possibility to intercept when a user clicks on a html button? I ve an webviewclient that load a login page with two buttons. Allow and Deny. I would you like to interc

Solution 1:

You are probably not getting a callback to shouldOverrideUrlLoading() because that is only called if the user triggers the navigation - if you use jquery/javascript or some other kind of redirect, then it will not be called.

If you are in control of the web page, you can add can a JavaScriptInterface to call back to your Android app an handle it however you like here: http://developer.android.com/guide/webapps/webview.html#BindingJavaScript

With JSI you simply register a function in your app and then call it in the page's javascript.

If you are not in control of the website, you can still inject the javascript yourself if you are familiar with the structure/DOM of the web page.

Solution 2:

Sounds like a case for implementing WebViewClient.shouldOverrideUrlLoading(), surely?

Post a Comment for "Intercept Html Button Click"