10

I've got an issue with Android WebView, I want to open a URL with target='_blank' in the same WebView, just as all other URLs are opening.

Also note that im overriding this method of WebViewClient 'shouldOverrideUrlLoading', for handling URL redirects (so that all URL redirects are opened in my WebView) but in case of URLs with target='_blank' this method doesn't get fired.

Kindly help! Thanks in advance.

2
  • We're you ever able to find a solution to this issue?
    – Caimen
    Mar 18, 2014 at 17:45
  • I recently opened one URL having target="_blank" in the same webView. What was happening in your case?
    – Darpan
    Nov 19, 2014 at 10:53

3 Answers 3

2

Try to add :

webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setSupportMultipleWindows(false);

And in shouldOverride :

view.loadUrl(url);
return true;
0
2
WebSettings settings = webView.getSettings();

//Enable support multiple windows
settings.setSupportMultipleWindows(true);

webView.setWebChromeClient(new WebChromeClient() {
    @Override 
    public boolean onCreateWindow(WebView view, boolean dialog, boolean userGesture, Message resultMsg)
    {
        //return true or false after performing the URL request
    }
 });
0

Try adding a WebChromeClient and handling onCreateWindow().

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.