Phonegap/Cordova: iOS not loading iframe content

时间:2016-07-11 19:01:38

标签: html ios cordova iframe mobile

I am trying to get iframes to work on iOS using Cordova CLI 6.2.0 and PhoneGap Desktop 0.3.3 . I have also asked for help at https://groups.google.com/forum/#!topic/phonegap/m1PPJuHtS8M

The iframes were working earlier in March, but have since stopped working. Due to attempts finding a solution, and other delays, I wasn't able to ask earlier and know the precise version numbers of when the error started.

To test possibilities, I made a simple app to test functionality. The parts I think are relevant include this of index.html here:

    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/page.css" />
    <script type="text/javascript" src="js/jquery-1.12.3.min.js"></script>

    <title>Webpage Bring In Test</title>
</head>
<body>
    <div class="app">

        <p>First Paragraph</p>

        <iframe class="viewerStuff" src="http://www.uwsp.edu/library/Pages/default.aspx">
            <p>IFrame failed.</p>
        </iframe>

        <p>Second Paragraph</p>

        <object type="text/html" data="http://www.uwsp.edu/library/Pages/default.aspx" class="viewerStuff">
            <p>Object failed.</p>
        </object>

        <p>Third Paragraph</p>

        <p>-Update successfully loaded, though-</p>
    </div>

and config.xml here:

<feature name="IntentAndNavigationFilter">
<param name="ios-package" value="CDVIntentAndNavigationFilter"/>
<param name="onload" value="true"/>
</feature>
<access origin="*"/>
<allow-intent href="http://*/*"/>
<allow-intent href="https://*/*"/>
<gap:plugin name="org.apache.cordova.whitelist" source="npm" />
<plugin name="cordova-plugin-whitelist" version="1"/>
<allow-navigation href="*" />
<platform name="ios">
    <allow-intent href="itms:*"/>
    <allow-intent href="itms-apps:*"/>
</platform>

There are other parts, but I don't think they are relevant.

Here's a picture of what it looks like on the Ipad being tested on. https://lh3.googleusercontent.com/-NGwIXwKz5q0/V369CMFBzwI/AAAAAAAAAtE/EquMiMl0a1gDdkBFbp8kTTGiyRISF0YvwCLcB/s1600/Iframe%2BIOS%2BTests%2B4%2B07072016.jpg I'm linking it as I don't have enough history on StackExchange to embed pictures.

Also, I can't use XCode for the solution. The place I am developing the app for doesn't want OS specific coding as part of their policy.

Let me know if you need more information or have any questions.

1 个答案:

答案 0 :(得分:0)

尝试将index.html中的Content-Security-Policy编辑为:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com *; style-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src 'self' data: content:; script-src * 'self' 'unsafe-inline' 'unsafe-eval';">
相关问题