如何获得web视图iframe的链接,启动浏览器? [英] How to get Webview iframe link to launch the browser?

查看:187
本文介绍了如何获得web视图iframe的链接,启动浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的WebView显示一个页面中的HTML包括一个iframe,其中SRC =xxxxx.php。

I'm using a WebView to display a page in which the html includes an iframe where src="xxxxx.php".

这IFRAME载荷与下面的链接广告形象。如果我点击该图片(链接),它会尝试加载原来的iframe中的新页(不显示在多那么一点的空间)。我希望发生的是点击链接到一个新的浏览器窗口中打开页面提及,留给我的应用程序不变。

This iframe loads as an ad image with an underlying link. If I click on that image (link), it tries to load the new page within original iframe (which doesn't show much in that little space). What I want to happen is clicking on the link to open the referred page in a new browser window, leaving my app as is.

如果我使用Android浏览器显示原来的页面,点击这个iframe中,它加载的链接作为一个新的页面。我如何得到一个web视图相同的行为?使用与shouldOverrideUrlLoading()一个WebViewClient似乎并没有被IFRAME链接调用。

If I use the Android browser to display the original page and click on this iframe, it loads the link as a new page. How do I get the same behavior with a WebView? Using a WebViewClient with shouldOverrideUrlLoading() doesn't seem to be called by the iframe link.

推荐答案

我在一个web视图源曾与谷歌的广告类似的问题,因为他们在iframe装载为好。这是我如何解决它:

I had a similar issue with google ads in a WebView source, since they load in an iframe as well. This is how I resolved it:

尝试在你的WebViewClient,通常在你shouldOverrideUrlLoading()

Try this in your WebViewClient, typically under your shouldOverrideUrlLoading()

            @Override
            public void onLoadResource (WebView view, String url) {
                if (url.contains("googleads")) {
                    if(view.getHitTestResult().getType() > 0){
                        view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                        view.stopLoading();
                        Log.i("RESLOAD", Uri.parse(url).toString());
                    }
                }
            }

这篇关于如何获得web视图iframe的链接,启动浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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