Anupam Anupam - 10 months ago 77
Android Question

Display a part of the webpage on the webview android

I want to make an app which loads the content from the webpage into webview. I want to show only a particular thing in the entire webview, not the whole content of the webpage.

Here is an example. If I use: as the URL for the webview, it loads all the contents of the page on the webview. But I want to remove the banner of the page and show it on the webview of my application.

I have tried using adblocker using CSS tags, but that is not helping me. Please give me some idea for overcoming this problem.


Answer Source

Thank You for the answer Zyber. I have solved it using injection of JavaScript in the code for WebView in android.

final WebView webview = (WebView)findViewById(;
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url)
    webview.loadUrl("javascript:(function() { " +
            "document.getElementsByTagName('header')[0].style.display="none"; " +

This solved my purpose and it is easy to use to.