Android的WebView功能的Java-Javascript的桥梁桥梁、功能、WebView、Android

2023-09-06 07:20:34 作者:奔溃边缘

我不知道是否有可能获得从Java code Javascript的变量值。换句话说,我已经得到了JS code。在web视图,我需要能够获得从的WebView的JS code变量。

I wonder if it's possible to obtain Javascript variable value from Java code. In other words, I've got JS code in WebView and I need to be able to obtain variables from that JS code from WebView.

推荐答案

是的,它可以通过安装Java-JS桥,然后注射到JS收集数据,并通过JS桥返回该页面。看到这个答案:How从Android的调用JavaScript?

Yes it's possible by installing Java-JS bridge and then injecting JS into page that collects the data and returns it via JS bridge. See this answer: How to call javascript from Android?