I was able to remove the header and footer and load the webpage using loadDataWithBaseURL() method
Document document = Jsoup.connect(mUrl).get(); document.getElementsByClass("header-container").remove(); document.getElementsByClass("footer").remove(); WebSettings ws = mWebView.getSettings(); ws.setJavaScriptEnabled(true); //mWebView.loadData(document.toString(),"text/html","utf-8"); mWebView.loadDataWithBaseURL(mUrl,document.toString(),"text/html","utf-8","");
As per the developer docs :
Note that JavaScript's same origin policy means that script running in a page loaded using this method will be unable to access content loaded using any scheme other than 'data', including 'http(s)'. To avoid this restriction, use loadDataWithBaseURL() with an appropriate base URL.
http://developer.android.com/reference/android/webkit/WebView.html#loadData(java.lang.String, java.lang.String, java.lang.String)