1.通过重写webview的shouldOverrideUrlLoading 方法来过滤某些连接 从而打开额外的浏览器;
this.appView.setWebViewClient(new CordovaWebViewClient(this, this.appView) { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if(url.contains("shoulduseexternalbrowser:")) { url = url.replace("shoulduseexternalbrowser:", ""); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); return true; } else { return super.shouldOverrideUrlLoading(view, url); } } });
2. 在HTML中的URL如(http://www.baidu.com/) 修改成
<a href="shoulduseexternalbrowser:http://www.baidu.com/">打开额外的浏览器</a>
浙公网安备 33010602011771号