且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

拦截html按钮点击

更新时间:2023-02-08 08:50:55

您可能没有收到对 shouldOverrideUrlLoading() 的回调,因为只有在用户触发导航时才会调用该回调 - 如果您使用 jquery/javascript 或其他类型重定向,那么它不会被调用.

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.

如果您控制着网页,您可以添加一个 JavaScriptInterface 来回调您的 Android 应用程序并根据您的喜好在此处处理它:http://developer.android.com/guide/webapps/webview.html#BindingJavaScript

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

使用 JSI,您只需在应用中注册一个函数,然后在页面的 javascript 中调用它.

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

如果您无法控制网站,如果您熟悉网页的结构/DOM,您仍然可以自己注入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.