我正在使用YouTube's HTML5 API,效果非常好,但JavaScript控制台一直显示此错误:
阻止原始“
http://www.youtube.com
”的框架访问原点为“http://localhost
”的框架。协议,域和端口必须匹配。
我的代码确实包含一个“origin”变量,但这似乎没有太大变化:
playerVars: { 'wmode': 'transparent', 'rel':0, 'modestbranding':0,
'autoplay': 1, 'controls': 0, 'showinfo':0, 'origin':'http://localhost'},
这个错误应该发生吗?我是否需要预防它以及如何预防?
这是整个'玩家'代码。似乎没有调用onStateChange事件。没有控制台日志消息。
var t = this;
player = new YT.Player('player', {
width: '685',
height: '385',
videoId: strMovie,
playerVars: { 'wmode': 'transparent', 'rel':0, 'modestbranding':0, 'autoplay': 1, 'controls': 0, 'showinfo':0, 'origin':'http://projects.eerkmans.nl'},
events: {
'onReady': function(e) {t.onPlayerReady(e)},
'onStateChange': function(e) {
console.log("state change");
t.onPlayerStateChange(e);
}
}
});