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>

 

posted on 2015-01-12 18:26  ทดสอบ  阅读(367)  评论(0)    收藏  举报