LathikaShetty
LathikaShetty

Reputation: 441

Get visible text from webview in android

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

Answers (1)

Crepi
Crepi

Reputation: 655

You should get innerText instead of innerHtml:

document.getElementsByTagName('html')[0].innerText

Upvotes: 4

Related Questions