How to get javascript function value in webview component

How can I get the value of a Javascript function from a webpage loaded using a webview component?

+4
source share
1 answer

You cannot directly.

You can call the Javascript function via loadUrl("javascript:...") , where ... is your function call. However, you cannot get the result this way.

If you inject a Java object into a web page using addJavascriptInterface() , you can configure another function that called the function you want and returns that value by calling the entered Java object. This only works if you can change the web page.

+2
source

Source: https://habr.com/ru/post/1301568/


All Articles