How to retrieve Javascript function value in webview component

无人久伴 提交于 2019-12-02 07:11:29

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3547748/get-the-values-of-the-fields-in-a-form-in-an-android-webview-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!