开发者

WebView: accessing JavaScriptInterface from multiple pages

In a WebView, how do you access the JavaScriptInterface from multiple web pages, and not just from the page that you load via mWebView.loadUrl(…)

e.g.

In my project's assets folder, I have:

index.html
page1.html
page2.html

... and here is the relevant WebView code:

webView.addJavascriptInterface(new JavaScriptInterface(), "android");
webView.loadUrl("file:///android_asset/index.html");

So at different points in time, a us开发者_JAVA技巧er may look at index.html, page1.html, etc. From what I can tell, only the JavaScript in index.html has access to the JavaScriptInterface via "window.android.someMethodName()". When I try to make a call to "window.android.someMethodName()" from page1.html, it says that "window.android" is not defined.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜