当没有网络时,加载网络资源,如 http://www.baidu.com/ 就会出现白色的页面;这是不希望出现的结果;所以希望能加载自己本地的HTML;
则需要重写 webview 的onReceivedError 方法,让它重新加载本地HTML;
super.appView.setWebViewClient(new CordovaWebViewClient(this, appView) { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.i("failerror no no my ", "http://www.baidu.com/ is erro ,please check your network ......"); loadUrl(launchUrl); super.onReceivedError(view, errorCode, description, failingUrl); } });
浙公网安备 33010602011771号