如何在webview中获取javascript隐藏标题

时间:2018-01-12 04:13:42

标签: android webview

我的webview加载javascript onPageFinish以隐藏标题我的网站代码如下:
我的代码:

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final WebView webView = view.findViewById(R.id.webview);
    CustomWebClient customWebClient=new CustomWebClient();
    webView.setWebViewClient(customWebClient);
    WebSettings webSettings = webView.getSettings();
    webSettings.setDomStorageEnabled(true);
    webSettings.setJavaScriptEnabled(true);
    webView.loadUrl("https://ticketgo.vn/blog");
}

class CustomWebClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
        view.loadUrl("https:ticketgo.vn/blog");
        return true;
    }
    @Override
    public void onPageFinished(WebView view, String url) {
            view.loadUrl("javascript:document.getElementById('header').style.display='none';");

    }
}

}

我的结果如何适合它: enter image description here

0 个答案:

没有答案