The situation is as follows:
I have 2 YouTube videos that are hidden, when I click the link this opens the video.
Now trying to use the Youtube API, which I want to give me some data, I mark the following error:
Failed to execute 'postMessage' on 'DOMWindow'
It is worth mentioning that I am at the local level and I want to know what that problem is.
This is my code:
$("#primervideo").click(function(e){
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
});
function onYouTubeIframeAPIReady() {
var player;
player = new YT.Player('yt_video', {
events: {
'onStateChange': onStateChange
}
});
}
This I occupy when I click on the link that calls the iframe, obviously this iframe is hidden and activated by a link
<iframe width="560" height="315" src="https://www.youtube.com/embed/RSo2gq8wTYw?autoplay=1&rel=0&showinfo=0&version=3&enablejsapi=1" frameborder="0" allowfullscreen></iframe>