Ada*_*dam 10 youtube iframe firefox google-chrome youtube-api
我使用iFrame在我的网站上嵌入了YouTube视频.我想使用API暂停视频,但在Chrome中我收到错误消息:
Unsafe JavaScript attempt to access frame with URL http://subdomain.example.com/ from frame with URL http://www.youtube.com/embed/KmtzQCSh6xk?enablejsapi=1&origin=http://subdomain.example.com. Domains, protocols and ports must match.
Run Code Online (Sandbox Code Playgroud)
在Firefox(3.6)中我收到此错误:
Permission denied for <http://www.youtube.com> to call method Location.toString on <http://subdomain.example.com>.
Run Code Online (Sandbox Code Playgroud)
我已尝试将iFrame放入自己或使用API添加它.无论哪种方式玩家进入,但我没有API控制它.
这是我的代码的相关部分:
<div id="player"></div>
<script type="text/javascript">
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '433',
width: '731',
videoId: 'KmtzQCSh6xk'
});
}
$("#pause_button").click(function(){
alert("Pausing " + player);//is undefined :(
player.pauseVideo();
});
</script>
Run Code Online (Sandbox Code Playgroud)
如何让浏览器允许YouTube iFrame访问我网页的主框架?
谢谢!
| 归档时间: |
|
| 查看次数: |
14583 次 |
| 最近记录: |