我试图通过android Webview Activity调用一个javascript函数setGameName(),但它抛出未捕获的ReferenceError:setGameName未定义于:1.
我的源代码如下:
webView2.setWebChromeClient(new WebChromeClient());
webView2.getSettings().setLightTouchEnabled(true);
webView2.getSettings().setJavaScriptEnabled(true);
webView2.addJavascriptInterface(jsInterface,"AndroidFunction");
webView2.loadUrl("file:///android_asset/www/index.html");
webView2.loadUrl("javascript:setGameName()");
它正在加载index.html,但在函数调用时抛出异常,
请提供适当的解决方案..
更新:
i have found the problem the page is not getting loaded at the time of function call..(Since on giving a time delay of 5000ms it is getting called..)!!
但是我如何实施呢?
最佳答案
原文链接:https://www.f2er.com/js/429718.html