简体   繁体   中英

How do you open a new link in the default browser rather than the webview with Javascript?

The links always open up in the webview rather than the default internet browser for android

Also I am using an Iframe

You can use WebViewClient for handle redirect page in WebView.

Just set WebViewClient in your WebView .

mWebView.setWebViewClient(new MyWebViewClient());

Create class for WebViewClient and you handle next page.

private class MyWebViewClient extends WebViewClient {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
             Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
             startActivity(browserIntent);
            Log.d("URL", " : " + url);
            return true;
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM