通过原点"file://"访问具有原点"https://www.youtube.com"的框架

man*_*ish 6 youtube iframe youtube-api cordova youtube-iframe-api

我有一个youtube的网址:

<iframe class="embed-responsive-item" ng-src="https://www.youtube.com/embed/s7gJ74ARN84" allowfullscreen=""></iframe>
Run Code Online (Sandbox Code Playgroud)

如果我在我的本地html文件中使用它,它可以很好地运行.但是,当我在phonegap ios app html页面中粘贴相同内容并在ios模拟器中运行时,它会显示以下错误,就像我点击视频一样:

Blocked a frame with origin "https://www.youtube.com" from accessing a frame with origin "file://".  

The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "file". Protocols must match.
Run Code Online (Sandbox Code Playgroud)

解:

它不是在模拟器中工作,而是在移动设备上工作,这是我的最终目标.

小智 -1

@曼尼什,

您似乎遇到了CORS问题。您可以添加到您的config.xml <access origin="*"/>

杰西