问题描述
我有一个网络视图.一切工作正常,但是当我打开包含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?
推荐答案
首先添加硬件加速,然后将以下几行添加到您的webView
First add Hardware Acceleration and add the following lines to your webView
webView.setWebChromeClient(new WebChromeClient());
编辑1
很难发现问题,但是尝试添加WebChromeClient
,WebViewClient
,并且不要忘记在加载像这样的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中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!