html - Android: How to show only one class from website in webview in android -
webviewclient yourwebclient = new webviewclient() { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return false; } @override public void onpagefinished(webview view, string url) { webview.loadurl("javascript:document.getelementbyclassname('storytieup');"); } }; webview = (webview) findviewbyid( r.id.browser ); webview.getsettings().setjavascriptenabled(true); webview.getsettings().setsupportzoom(true); webview.getsettings().setbuiltinzoomcontrols(true); webview.setwebviewclient(yourwebclient); webview.loadurl("http://stars.nhl.com/club/newsindex.htm");
this webviewclient code want display div contents class name 'storytieup', when run code shows whole website contents, need 1 div show in webview, use jsoup in portions here don't want use jsoup because of reasons, there solution display 1 div class name, in advance
first, please remove view.loadurl(url);
shouldoverrideurlloading
. it's not needed , causes performance issues. url load in progress; don't need start again.
i don't think there's simple way delete nodes other storytieup
in html document. perhaps take innerhtml
of node , form html new document display.
calling javascript onpagefinished
may non-deterministic. callback invoked when resources of page have been loaded network , not when have been parsed or dom has been constructed. means javascript may fail.
the code have @ moment select element, doesn't it.
Comments
Post a Comment