How to retrieve Javascript function value in webview component

前端 未结 1 874
难免孤独
难免孤独 2021-01-25 18:02

How can I retrieve the Javascript function value from a web page loaded withing a webview component??

相关标签:
1条回答
  • 2021-01-25 18:26

    You can't, directly.

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

    If you inject a Java object into the Web page via addJavascriptInterface(), you could set up another function that called the function you want and returns that value via a call to the injected Java object. That only works if you can modify the Web page, though.

    0 讨论(0)
提交回复
热议问题