I saw the related topic but I could not get it to function.
I need to remove a search bar and a navigation dropdown from a web view I am using.
My code is below.
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url)
{
webView.loadUrl("javascript:(function() { " +
"document.getElementsById('omc-main-navigation')[0].style.display = 'none'; " +
"})()");
}
});
webView.loadUrl(links.get(arg2));
There isn't any method like document.getElementsById()
.
Use
document.getElementById()
instead of the
document.getElementsById() // "s" is extra here.
It should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.