无法使用cordova iOS在iframe中正确加载外部网址 [英] Can't properly load external URLs in an iframe with cordova iOS

查看:1755
本文介绍了无法使用cordova iOS在iframe中正确加载外部网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助。有人知道为什么我不能在phonegap / cordova iOS中一直将URL加载到iframe中吗?
我注意到有些页面只是拒绝在iframe中加载,而其他页面加载就好了。我似乎也无法加载基于SSL的站点。示例:

I need help. Anybody knows why I can't consistently load URLs into iframes within phonegap/cordova iOS? I noticed that some pages simply refuse to load inside an iframe while others will load just fine. I also can't seem to get SSL based sites to load. Examples:

<iframe src="http://ucla.edu"></iframe> //loads correctly
<iframe src="http://google.com"></iframe> //refuses to load
<iframe src="http://www.ufrj.br"></iframe> //loads correctly
<iframe src="http://192.168.20.95"></iframe> //loads correctly (this a local server I have inside my work network)
<iframe src="https://192.168.30.15"></iframe> //refuses to load (this also a local server but with a valid ssl cert (signed by startcom/startSSL)

我添加了stay-in-webview并将访问源标签添加到config.xml(我可以在iframe中加载一些外部页面),但不确定为什么这种行为不一致。我用来开发的Mac可以加载所有这些都是正确的。

I added stay-in-webview and access origin tags to config.xml (I can load SOME external pages in the iframe) but not sure why this behavior is not consistent. The Mac I'm using to develop can load all these properly.

我是新手,因此在开始将旧的webApps移植到移动平台之前,我正在努力解决基本问题。
我的开发系统有:
Lion
Cordova 2.5
xCode 4.6

I am new to this so I am trying things out to wrap my head around the basics before start "porting" my old webApps into mobile platforms. My dev systems has: Lion Cordova 2.5 xCode 4.6

欢迎任何帮助。谢谢!

推荐答案

我想我明白了。如果有其他人误解我的话,我会把它发布在这里。

I think I got it. I will post it here in the case someone else falls in the same misconception I did.

查看常规桌面浏览器中的响应标题,我注意到移动应用iframe中未加载的页面具有 X-Frame-Options:SAMEORIGIN 在他们的回复中设置hea ders。
此选项告诉Web浏览器不要在框架中加载该页面,除非该窗口属于同一个源。由于我的iframe不符合条件,因此页面不会加载。 https://developer.mozilla.org/en-US/docs / HTTP / X-Frame-Options

Looking at the response headers in my regular desktop browser I noticed that the pages which won't load in the mobile app iframe have the X-Frame-Options: SAMEORIGIN set in their response headers. This option tells the web-browser NOT to load that page in a frame unless the window belongs to the same origin. Since my iframe doesn't qualify, the page won't load. https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options

我还(错误)理解了config.xml的目标,同时列出:白名单是应用程序可以放置的位置访问。它与应用程序可以接收的内容几乎没有关系。我的不好。

I had also (mis)understood the goal of the config.xml whilelisting: That whitelisting is places the app can visit. It has little to do with what can be received by the app. My bad.

我会尝试使用cordova的childbrowser插件并希望获得更好的结果。
https://github.com/macdonst/phonegap-plugins / tree / master / Android / ChildBrowser

I will try working with the childbrowser plugin for cordova and hope for better results. https://github.com/macdonst/phonegap-plugins/tree/master/Android/ChildBrowser

-rod

这篇关于无法使用cordova iOS在iframe中正确加载外部网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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