I am trying to load youtube into my web page using YouTube iFrame Player API
, and getting following error while loading:
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').
both origin and target are https
, there are few SO post which resolves the issue by keeping origin & target url to https. In this case both are same.
Following is the JS code I am used to load the player dynamically:
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
}
});
}
<head>
section. Move it to<body>
section at below but before<script src='https://www.youtube.com/iframe_api'></script>
works fine. – Palatalized