Cordova iOS空白iframe [英] Cordova iOS blank iframe

查看:270
本文介绍了Cordova iOS空白iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在处理的Cordova应用中,有一个iframe。问题是,在测试应用程序(模拟器和设备)时,iframe是空白的。在Android上,iframe工作正常。

In a Cordova app that I am working on there is an iframe. The problem is that when testing the app (both simulator and on device) the iframe is blank. On Android the iframe works perfectly however.

iframe是在Angular指令中动态加载的。

The iframe is loaded dynamicly in an Angular directive.

指令链接函数以下代码用于加载iframe并将其附加到指令的元素:

Within the directive link function the following code is used to load and append the iframe to the directive's element:

var iframe = angular.element('<iframe class="widget" width="' + widgetWidth + '" height="' + widgetHeight + '"></iframe>');
iframe.attr('src', url);
element.append(iframe);

我也尝试过以下几行:

var iframe = document.createElement('iframe');
iframe.src = url;

这导致如下所示(使用Safari网络检查员):

This results in somthing like the following (using Safari web inspector):

<iframe class="widget" width="384" height="505" src="http://hostname/correct/uri"></iframe>

在我的index.html文件中,我有以下设置:

In my index.html file I have the following set:

<meta http-equiv="Content-Security-Policy" content="script-src * 'unsafe-eval'; connect-src * 'unsafe-eval'; object-src 'self'; style-src * 'unsafe-inline';">

我的cordova config.xml中还有以下行:

I also have the following lines in my cordova config.xml:

<access origin="*" subdomains="true" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

Safari Web Inspector中也没有错误或警告。

There is also no errors or warnings in Safari Web Inspector.

所以我的问题是,是否有一些技巧让iFrames在我缺少的Cordova iOS应用程序中运行。或者我当前的配置/代码有什么问题?

So my question is, is there some trickery to get iFrames to work in Cordova iOS apps that I am missing. Or what is wrong with my current config/code?

我正在使用angularjs 1.5.3并且有jquery 2.2.1(在angularjs之前加载)以防万一。 / p>

I am using angularjs 1.5.3 and have jquery 2.2.1 (loaded before angularjs) in case that helps.

推荐答案

问题是allow-navigation标签。所以要解决它我只需要将< allow-navigation href =*/> 标记放入项目的config.xml文件中。

The problem was the allow-navigation tag. So to solve it I only had to put the <allow-navigation href="*" /> tag into the project's config.xml file.

我在模拟器运行时通过xcode的输出框找到了解决方案。有一条消息包含有问题的iframe的网址以及内部导航被拒绝的内容。

I came to the solution through the output box in xcode while the simulator was running. There was a message containing the url of the iframe in question and something about "internal navigation rejected".

这篇关于Cordova iOS空白iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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