|在Android System Webview (52.0.2743.98) 的最新更新后,我注意到使用onJsAlert 方法无法执行javascript。
更具体地说,以下代码在最新更新后停止工作
private class MyWebChromeClient extends WebChromeClient {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
view.loadUrl(javascript:(function(){CustomInterface.completeAction(document.head.innerHTML)})());
return super.onJsAlert(view, url, message, result);
}
}
我还检查了接口是否设置正确
mWebView.setWebChromeClient(new MyWebChromeClient());
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new CustomInterface(), "CustomInterface");
有没有人遇到过同样的问题?