Intercept html button click

旧城冷巷雨未停 提交于 2021-02-10 05:46:29

问题


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


回答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.




回答2:


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



来源:https://stackoverflow.com/questions/4396450/intercept-html-button-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!