0

谁能给我一个例子如何只查看网站的一部分?我知道如何使用 webview 加载网站,但正如我所说,我只想加载表格(链接)

提前致谢,

4

2 回答 2

1

让我们试试这个...

public class WebClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) {
       view.loadUrl("javascript:document.getElementByClassName('example')"); 
    }

    }

看看这个链接

于 2013-06-15T13:28:56.323 回答
0

在 Kotlin 中这样:

view.webViewClient = object : WebViewClient() {
            override fun onPageFinished(view: WebView, url: String) {
                view.loadUrl(
                    "javascript:(function() { " +
                            "var head = document.getElementsByClassName('header')[0].style.display='true'; " +
                            "var head = document.getElementsByClassName('art-bnr')[0].style.display='none'; " +
                            "var head = document.getElementsByClassName('container-box')[0].style.display='none'; " +
                            "var head = document.getElementsByClassName('blog-sidebar')[0].style.display='none'; " +
                            "var head = document.getElementsByClassName('footer-container')[0].style.display='none'; " +
                            "})()"
                      ) } }

            view.loadUrl(url)
于 2021-03-11T16:59:16.720 回答