我正在工作的一些javascript注入到我的android webview。我只是不完全确定它在寻找
的语法我想在我的html页面调用这个函数:$(document).ready(function({...})
我有一个webview和javascript界面设置在我的应用程序。我也有javascript启用
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/mydocument.html");
myWebView.addJavascriptInterface(new myJavaScriptInterface(), "jsintector");
myWebView.loadUrl("javascript:ready()");
javascript:ready()
应该是android中调用html页面中正确函数的部分。访问这个函数的正确语法是什么?$(document).ready(function({...})
(编辑:javascript已经在html中,我只是想强制它从android端运行)
尝试在…之前搜索
无论如何,最简单的方法是这样做:
-
load the url into a string
-
inject the javascript into the string
- 使用loaddata将html加载到webview