这是我得到的错误消息:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided
('https://www.youtube.com') does not match the recipient window's origin
('http://localhost:9000').
Run Code Online (Sandbox Code Playgroud)
我已经看到了目标来源http://www.youtube.com和收件人来源的其他类似问题https://www.youtube.com,但没有一个像我的目标所在的地方https://www.youtube.com和原点http://localhost:9000.
我在heroku有一个游戏,现在我试图让它在Facebook画布上工作,但是,虽然它适用于Firefox,但在Chrome和IE中却没有.
IE显示带有按钮的警告,单击按钮时,它会显示内容.
在chrome中,我收到此错误:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://game.herokuapp.com') does not match the recipient window's origin ('null').
Run Code Online (Sandbox Code Playgroud)
怎么了?
YouTube是否已开始锁定跨源请求?
我在我的网站上使用全屏自动播放英雄视频,它已经运行了很长时间.在过去的几周内它停止工作,我在日志中有以下错误.
无法在'DOMWindow'上执行'postMessage':提供的目标来源(' https://www.youtube.com ')与收件人窗口的来源(' https://tbrogames.github.io ')不匹配.
根据这个问题的答案
我尝试在http和https之间更改主机以查看是否会修复它而它没有.
我的网站抛出错误:https://tbrogames.github.io/
我找到了一个更大的游戏网站也有这个问题. https://playbattlegrounds.com/main.pu
他们还使用youtube视频作为英雄/启动视频; 并且它不再起作用,抛出相同的错误.
相关的JavaScript可以在这里找到 https://github.com/tbrogames/tbrogames.github.io/blob/master/js/defer.js
但是,这工作了很长时间,我没有改变任何代码.这就是为什么我认为这是YouTube所做的改变.
我正在尝试在打开模态时启动youtube视频,直到完成后才进入下一页.
我的下面的脚本适用于Chrome,但在Firefox和Edge中会产生此错误.
无法在'DOMWindow'上执行'postMessage':提供的目标源(' https://www.youtube.com ')与收件人窗口的原点(' http://example.com ')不匹配.
使用Javascript
<script src="http://www.youtube.com/player_api"></script>
<script>
// autoplay video
function onPlayerReady(event) {
event.target.playVideo();
}
// when video ends
function onPlayerStateChange(event) {
if(event.data === 0) {
alert('Thank you for watching - Click OK to see your results');
}
}
</script>
<script language="JavaScript">
$(document).ready(function() {
$('#post_form').submit(function() { // catch the form's submit event
$("#adModal").modal("show");
var time = $('#adtime').val();
//startCountdownTimer(time) ;
// create youtube player
var player;
player = new YT.Player('player', {
width: '640',
height: '390',
videoId: 'EF-jwIv1w68', …Run Code Online (Sandbox Code Playgroud)