private void initWebview(){//mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);//mWebView.setLayerType(View.LAYER_TYPE_NONE, null);//设置支持jsmWebView.getSettings().setJavaScriptEnabled(true);//设置渲染效果优先级,高mWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);//设置缓存模式mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);String cacheDirPath = APP_CACAHE_DIRNAME;//设置数据库缓存路径mWebView.getSettings().setDatabasePath(cacheDirPath);//设置 应用 缓存目录mWebView.getSettings().setAppCachePath(cacheDirPath);//开启 DOM 存储功能mWebView.getSettings().setDomStorageEnabled(true);//开启 数据库 存储功能mWebView.getSettings().setDatabaseEnabled(true);//开启 应用缓存 功能mWebView.getSettings().setAppCacheEnabled(true);mWebView.getSettings().setAppCacheEnabled(true);mWebView.setWebChromeClient(new WebChromeClient());//这行最好不要丢掉mWebView.loadUrl("https://ggzy./xjy/Jyxt/MeetingRoomDoorPlate.aspx?area=4&type=1");Log.d("hhhhhhhhhhh","onCreate.....................");//mWebView.loadUrl("");//设置响应超链接,在安卓5.0系统,不使用下面语句超链接也是正常的,但在M安卓4.4.4中需要使用下面这条语句,才能响应超链接mWebView.setWebViewClient(new WebViewClient(){@Overridepublic boolean shouldOverrideUrlLoading(WebView view, String url) {// TODO Auto-generated method stubview.loadUrl(url);Log.d("hhhhhhhhhhh","shouldOverrideUrlLoading.....................");return true;}@Overridepublic void onReceivedSslError(WebView view,SslErrorHandler handler, SslError error) {// TODO Auto-generated method stub//super.onReceivedSslError(view, handler, error);Log.d("hhhhhhhhhhh","onReceivedSslError.....................");handler.proceed(); //接受所有证书}});}
注:(以下两点是主要修改)
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.setWebViewClient 中的两个方法必须实现