我收到此错误:Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('<URL>') does not match the recipient window's origin ('<URL>').
我的页面按我希望的方式运行(我没有注意到任何不受欢迎的行为),但我从不喜欢忽略控制台中的错误,尤其是在我什至不了解根本原因的情况下。
我的问题不是重复的,因为我已经研究了所有这些问题,但没有一个答案有效:
我已经在使用
https
。我已经尝试将
playerVars
设置为 {origin: window.location.origin}
。我已经尝试过设置
host
。我已经尝试过更改 iframe 的可见性。
等等。
var playerVars = {origin: window.location.origin};//https://stackoverflow.com/a/50518247/470749
window.onYouTubeIframeAPIReady = function () {
for (var i = 0; i < youtube.length; i++) {
var youtubeLazyEl = youtube[i];
var videoId = youtubeLazyEl.dataset.v;
players[videoId] = new YT.Player(videoId, {
videoId: videoId,
//host: 'https://www.youtube.com', //https://stackoverflow.com/a/47914456/470749
//playerVars: playerVars,
});
}
};
想法?
最佳答案
由于您似乎在使用延迟加载,请尝试删除 iframes HTML 属性 loading="lazy"
- 为我解决了这个问题。
关于youtube - 无法在 'postMessage' : The target origin provided 'DOMWindow' ) does not match the recipient window's origin ('<URL>' ) 上执行 ('<URL>',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57649870/