我正在尝试在 iOS 9.3.1 上的 phonegap 应用程序中显示 iframe。由于某种原因(因此出现这个问题),iframe 出现在 android 上,但没有出现在 ios 上。
设置: 1. 在 mac 上,我安装了 PhoneGap desktop v0.3.1 并创建了一个新应用
在 index.html 中我添加了 iframe
<body> <iframe src="http://www.w3schools.com" style="border-style:solid; width:750px; height:500px;"/> <div class="app"> <h1>PhoneGap</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> </div> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript"> app.initialize(); </script> </body>
然后在安装了 PhoneGap 应用程序 ( https://itunes.apple.com/us/app/phonegap-developer/id843536693?mt=8 ) 的 iPad 上进行测试:在 Android 上它可以工作,而在 iOS 上它不显示(我可以看到边框,但看不到内容)
然后将 config.xml 更改为更加宽松
<access origin="*" /> <allow-intent href="*" /> <allow-navigation href="*" /> <plugin name="cordova-plugin-whitelist" version="1"/> <allow-intent href="*" /> <allow-navigation href="*" /> <platform name="android"> <allow-intent href="*" /> </platform> <platform name="ios"> <allow-intent href="*" /> </platform>
并添加 在 index.html 中
- 再次测试,结果与 3 相同。
最佳答案
从 Resources->ProjectName-Info.plist 打开您的 Info.plist 文件。
添加以下详细信息: App Transport Security Settings as Dictionary 并将 Allow Arbitrary Loads 添加为 true。
检查下图:
第二件事,您需要将外部主机添加为字符串,其中项目 0 具有 * 值。检查以下图片:
关于ios - ios 9.3.1 上 phonegap 应用程序中的 iframe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36835993/