Blackbelt
Blackbelt

Reputation: 157467

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 intercept when the deny button is pressed. (Deny and allow have the same basUrl and a js do the correct redirect).

thanks in advance

Upvotes: 2

Views: 2097

Answers (2)

Zambotron
Zambotron

Reputation: 699

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.

Upvotes: 3

Reuben Scratton
Reuben Scratton

Reputation: 38727

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

Upvotes: 0

Related Questions