在ios 9.3.1上的phonegap应用程序中使用iframe [英] iframe in a phonegap app on ios 9.3.1
问题描述
我正在尝试在iOS 9.3.1上的phonegap应用中显示iframe。出于某种原因(因此这个问题),iframe显示在Android上但不在ios上。
设置:
1.在Mac上,我安装了PhoneGap桌面v0.3.1并在index.html中添加了iframe
< body>
< iframe src =http://www.w3schools.comstyle =border-style:solid; width:750px; height:500px;/>
< div class =app>
< h1> PhoneGap< / h1>
< div id =devicereadyclass =blink>
< p class =event listening>正在连接到设备< / p>
< p class =event received>设备就绪< / p>
< / div>
< / div>
< script type =text / javascriptsrc =cordova.js>< / script>
< script type =text / javascriptsrc =js / index.js>< / script>
< script type =text / javascript>
app.initialize();
< / script>
< / body>
然后在带有PhoneGap应用的iPad上测试(
第二件事你需要将外部主机添加为字符串项目0具有*值。检查以下图片:
I'm trying to show an iframe in a phonegap app on iOS 9.3.1. For some reason (hence this question) the iframe shows up on android but not on ios.
Setup: 1. on a mac, i installed PhoneGap desktop v0.3.1 and created a new app
in index.html i added the 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>
then tested on an iPad with the PhoneGap app (https://itunes.apple.com/us/app/phonegap-developer/id843536693?mt=8) installed: on android it works while on ios it does not show up (i can see the border, but not the content)
then changed the config.xml to be more permissive
<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>
and added in index.html
- tested again with the same result as 3.
Open your Info.plist file from Resources->ProjectName-Info.plist.
Add below details: App Transport Security Settings as Dictionary and add Allow Arbitrary Loads to true.
Check underneath image:
And second thing you need to add External Hosts as a string with item 0 having * value. Check below images:
这篇关于在ios 9.3.1上的phonegap应用程序中使用iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!