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.
Try to add :
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setSupportMultipleWindows(false);
And in shouldOverride :
view.loadUrl(url);
return true;
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
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With