Android的WebView中新窗口的URL [英] Android WebView New Window URL

查看:117
本文介绍了Android的WebView中新窗口的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与Android问题的WebView ,我想打开一个URL与目标='_空白在同一个的WebView ,就像所有其他网​​址正在打开。

另外请注意,IM覆盖 WebViewClient 的这种方法的shouldOverrideUrlLoading ,用于处理URL重定向(以便所有URL重定向在打开我的的WebView ),但在URL中的情况下,与目标='_空白此方法不被解雇。

请帮助!先谢谢了。


解决方案

  WebSettings设置= webView.getSettings();//启用支持多个窗口
settings.setSupportMultipleWindows(真);webView.setWebChromeClient(新WebChromeClient(){
    @覆盖
    公共布尔onCreateWindow(的WebView视图,布尔对话框,布尔userGesture,留言resultMsg)
    {
        //执行URL请求后返回true或false
    }
 });

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.

解决方案

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
    }
 });

这篇关于Android的WebView中新窗口的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆