我有一个具有功能搜索子文档中的JS文件。
I have a JS file that has functions to search a document for substrings.
我想通过传递参数给它(搜索关键字)访问此文件中的函数。
I want to access functions inside this file by passing parameters to it (the search keyword).
我知道我们可以用.loadUrl(JavaScript的:~~~~~),但我不清楚如何使用多种功能来做到这一点。
I know we can use .loadUrl("javascript:~~~~~) but I'm not clear on how to do it using multiple functions.
任何人谁可以在正确的方向指向我?
Anyone who can point me in the right direction?
谢谢!
您可以试试这个。
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url){
webview.loadUrl("javascript:(function() { " +
"var script=document.createElement('script');" +
"script.type='text/javascript';script.src=" + jsFileURL + ";" +
"script.onload=function("+queryString+"){//it can be your search function};"
"document.getElementsByTagName('head').item(0).appendChild(script);"+
"})()");
}
});
webview.loadUrl("http://SOMEURL");
上一篇:是的lambda EX pressions多线程?是的、多线程、EX、lambda
下一篇:NoClassDefFoundError的:安卓/支持/ V4 /内容/ LocalBroadcastManager内容、NoClassDefFoundError、LocalBroadcastMana