开发者

Android WebView New Window URL

I've got an issue with Android WebView, I want to open a URL with target='_blank' in开发者_如何学JAVA 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
    }
 });


Try adding a WebChromeClient and handling onCreateWindow().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜