cordova - 无法使用 cordova iOS 在 iframe 中正确加载外部 URL

标签 cordova iframe ssl external

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

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

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

我对此很陌生,所以在开始将我的旧 web 应用程序“移植”到移动平台之前,我正在尝试围绕基础知识进行思考。 我的开发系统有: 狮子 Cordova 2.5 xCode 4.6

欢迎任何帮助。谢谢!

最佳答案

我想我明白了。我会把它贴在这里,以防其他人陷入与我相同的误解。

在我的常规桌面浏览器中查看响应 header ,我注意到不会在移动应用程序 iframe 中加载的页面在其响应 header 中设置了 X-Frame-Options: SAMEORIGIN。 此选项告诉网络浏览器不要在框架中加载该页面,除非该窗口属于同一来源。由于我的 iframe 不符合条件,因此页面不会加载。 https://developer.mozilla.org/en-US/docs/HTTP/X-Frame-Options

我还(误解)理解了 config.xml 的目标,同时列出:白名单是应用程序可以访问的地方。它与应用程序可以接收的内容无关。我的错。

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

-杆

关于cordova - 无法使用 cordova iOS 在 iframe 中正确加载外部 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15438054/

相关文章:

android - 请安装 Android 目标 : "android-21"

javascript - 如何使用javascript将iframe高度设置为100%

javascript - 从 Iframe 调用 EXTjs 中的父 Controller 函数

php - opencart View 不合适

internet-explorer - IE11 中的 "SSL network extender service is down"错误

android - Phonegap- 支持推送通知

javascript - Phonegap/Cordova 中的图像上传中 $_files 为空

javascript - JQuery 获取 IFrame 中的父 URL :iframe and its parent are in Different domain

ssl - 使用 let's encrypt 证书设置 Gunicorn