1、注册网络权限
<uses-permission android:name="android.permission.INTERNET" />
2、webView获取Settings,设置支持js
settings.setJavaScriptEnabled(true);
3、setWebChromeClient(WebView类中)辅助处理js
bridgeWebView.setWebChromeClient(new WebChromeClient(){ @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { return super.onJsAlert(view, url, message, result); } });
在webView的时候,记得清理缓存,不然会一直缓存之前的html,导致改变了html在手机端无效
WebSettings settings = bridgeWebView.getSettings(); settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
类似timeout,confirm都需要类似的配置
标签:String,settings,js,result,webView,android,alert,message From: https://www.cnblogs.com/linweimu/p/17046800.html