gpt4 book ai didi

android - 没有 Javascript 的 webview 中的按钮

转载 作者:行者123 更新时间:2023-11-30 03:41:33 26 4
gpt4 key购买 nike

我有一个从服务器加载 webview 的 android 应用程序。我没有服务器代码,所以我无法更改 Javascript 中的任何内容。我想弄清楚何时在 web View 中单击按钮以及按钮中的标签是什么。我不知道Id,我只想获取标签。

我尝试搜索此内容,但找不到答案。我找到了可以在 javascript 中工作的解决方案,但在我的情况下我不能。

最佳答案

此建议可能有助于找到有用的信息,从而确定您的按钮标签。为 WebViewClient 覆盖 shouldOverrideUrlLoading()shouldInterceptRequest() 和/或 onLoadResource() 以便您可以获取任何重定向的 URL。

例子:

webview.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {

// Try to learn something useful from the 'url' here.

// Continue as normal, loading the 'url' within this WebView.
view.loadUrl(url);
return false; // Allow the WebView to handle the request.
}

// Optional: Add similar for "shouldInterceptRequest()" and/or "onLoadResource()".
});

注意:如上覆盖 shouldOverrideUrlLoading() 是在同一 WebView 中保持重定向而不是重定向到默认浏览器的标准方法申请。

关于android - 没有 Javascript 的 webview 中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15620394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com