I'm working on a local server, experimenting with the YouTube iframe API.
When loading iframes I get the error message "Failed to execute 'postMessage' on 'DOMWindow".
How do I eliminate this error?
I'm working on a local server, experimenting with the YouTube iframe API.
When loading iframes I get the error message "Failed to execute 'postMessage' on 'DOMWindow".
How do I eliminate this error?
I tried the Getting Started in the IFRAME API page and was able to run the sample without a hitch using the python -m SimpleHTTPServer 8080
.
Your problem might be related to the way you're using iframe API. Check this SO post for more info.
I think we could customize the sendMessage of the YT.Player
playerOptions.playerVars.origin = window.location.origin or your domain.
this.youtubePlayer = new YT.Player(element,playerOptions);
this.youtubePlayer.sendMessage = function (a) {
a.id = this.id, a.channel = "widget", a = JSON.stringify(a);
var url = new URL(this.h.src), origin = url.searchParams.get("origin");
if (origin && this.h.contentWindow) {
this.h.contentWindow.postMessage(a, origin)
}
}
I used this function to resolve in my project. (Origin answer)