pupunzi / jquery.mb.YTPlayer

use a custom yutube player for a video as background on jQuery framework
https://pupunzi.com/mb.components/mb.YTPlayer/demo/demo.html
1.3k stars 431 forks source link

Failed to execute ‘postMessage’ on ‘DOMWindow’ #385

Closed jmbronson closed 5 years ago

jmbronson commented 6 years ago

I get this error with the player in my developer console: "Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://www.youtube.com’) does not match the recipient window’s origin (‘’)."

1). Some responses on the internet said to change all references of the Youtube link to https:// (example below) but this caused even more errors. 2). Another response said to add origin: 'https://mysiteurl.com' to the players paramVars, this had no effect on the error.

To explain #1 above, an example would be line #1936 of jquery.mb.TYPlayer.js "if (vURL.indexOf("http") < 0) vURL = jQuery.mbYTPlayer.locationProtocol + "//www.youtube.com/watch?v=" + YTPlayer.opt.videoURL;"

changed to:

if (vURL.indexOf("http") < 0) vURL = jQuery.mbYTPlayer.locationProtocol + "https://www.youtube.com/watch?v=" + YTPlayer.opt.videoURL;

Please fix this issue! The script works wonderfully but I am big on web standards and making things compliant and error-free.

Thanks!

pupunzi commented 6 years ago

Hi, This error is well known and it is generated by Youtube. There's no way to fix it other than Youtube itself. The script is already managing the protocol setting the HTTPS for SSL sites and HTTP for the other. On the next release, the inclusion of the iframe-api script will be asynchronous as explained here: https://issuetracker.google.com/issues/35174286. That should solve the problem.

All the best, Matteo