step1:create jsinterface class
class getHtmlListener{
@JavascriptInterface
public void getHtml(String html) {
LogUtil.e("result",html);
}
}
step2:addJavascriptInterface
webview.addJavascriptInterface(new getHtmlListener(), "HTMLOUT");
step3:loadUrl
...
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
myWebView.loadUrl("javascript:window.HTMLOUT.getHtml('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>');");
}
...