Android Webview Disable Wikipedia Search Bar
I'm building an app which using webView and loading Wikipedia's web pages. I would like to disable this part: I don't know what is the best way to do this... I have thought of aut
Solution 1:
By looking into Wikipedia's source code you can see that the search bar is located inside a div
container with the class name "header-container header-chrome". You are able to remove it from the view using JavaScripct
code and the HTML DOM getElementsByClassName() Method
.
The following code might help you with removing the search bar from the HTML page and display the rest.
WebView myWebViewDisply = (WebView) findViewById(R.id.WebViewDisply);
myWebViewDisply.getSettings().setJavaScriptEnabled(true);
myWebViewDisply.setWebViewClient(new WebViewClient() {
@Override
publicvoid onPageFinished(WebView view, String url) {
myWebViewDisply.loadUrl("javascript:(function() { " +
"document.getElementsByClassName
('header-container header-chrome')[0].style.display='none';"
+"})()");
}
});
myWebViewDisply.loadUrl(youUrl);
Post a Comment for "Android Webview Disable Wikipedia Search Bar"