0

I am trying get a var from a webview but I only can modify like this:

browser.loadUrl("javascript:var x = document.getElementById('login').value = 'something';");

but I need get any js var like this :

String myAndroidvar = browser.loadUrl("javascript:var x = document.getElementById('login').value");

but this syntax is incorrect, I need the correct method.

1
  • Use JSoup library for web scraping. I think it's the only way. Commented Jun 8, 2015 at 16:01

1 Answer 1

1

You have to add a javaScriptInterface to you webview. See this blog for a decent description. You can also get stuff from javascript by calling an interface function you defined using:

web.loadUrl("javascript: window.jsinterface.getValue(document.getElementById('login').value)");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.