iframe未加载到Webview android中 [英] Iframe not loading in webview android

查看:488
本文介绍了iframe未加载到Webview android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网络视图.一切工作正常,但是当我打开包含iframe的页面时,iframe无法显示.是否需要任何特定设置?

I have a webview. Everything is working fine but when I am opening a page which has iframe, the iframe is not getting visible. Are there any specific settings required?

推荐答案

首先添加

First add Hardware Acceleration and add the following lines to your webView

webView.setWebChromeClient(new WebChromeClient());

编辑1

很难发现问题,但是尝试添加WebChromeClientWebViewClient,并且不要忘记在加载像这样的URL之前启用javascript

It will be hard to identify the problem but try adding WebChromeClient, WebViewClient and also don't forget to enable javascript before loading URL like this

webView= (WebView) findViewById(R.id.webview); 
webView.setWebChromeClient(new WebChromeClient()); 
webView.setWebViewClient(new WebViewClient()); 
webView.getSettings().setJavaScriptEnabled(true);

编辑2

如果您确实需要加载iframe的内容,请尝试使用 Jsoup 加载html页面,但是您必须找到iframe并手动获取内容.

If you really need to load content of iframe then Try using Jsoup to load html page but you have to find the iframe and fetch the content manually.

Document doc=...
Element iframe1 = doc.select("#iframe1").first();

if (iframe1!=null) {
   Document iframeContent = Jsoup.connect(iframe1.attr("src")).get();

  }

其中iframe1是您的iframe的ID.

这篇关于iframe未加载到Webview android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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