0
執行的postMessage
我試圖到YouTube加載到使用YouTube iFrame Player API
我的網頁,並獲得以下錯誤而載入:的YouTube iFrame播放器API未能就DOMWindow
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://developer-sandbox.com').
都起源和目標是https
,有很少SO發佈通過保持原始&目標網址爲https解決問題。在這種情況下,兩者是相同的。
以下是JS代碼我用動態加載播放器:
showVideoPreview: function(youtube_id){
var meThis = this;
var player = new YT.Player('shoppable-video-container', {
height : '315',
width : '560',
videoId : youtube_id,
events : {
'onReady' : meThis.onPlayerReady,
'onStateChange' : meThis.onPlayerStateChange
}
});
}
對我來說,這是因爲jQuery是在'
'部分負荷。將它移動到''部分,但在'>之前工作正常。 – vee