Reputation: 441
How to get only visible text from webview?
I have tried this:-
webView.evaluateJavascript("(function(){return('<html>'+document.getElementsByTagName('html')[0].innerHTML+'</html>'); })();",
new ValueCallback<String>() {
@Override
public void onReceiveValue(String html) {
Log.d("HTML", html);
}
});
But i get html string. I only need text content.
Upvotes: 2
Views: 996
Reputation: 655
You should get innerText instead of innerHtml:
document.getElementsByTagName('html')[0].innerText
Upvotes: 4