207
While trying to make a video from youtube autoplay as the page loads this error popped up in the console.
Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided (‘https://www.youtube.com’) does not match the recipient window’s origin ('https://yourdomain.com')
I found the following solutions.
- You need to have ssl (https) enabled. and add at the end of your url “;origin=https://yourdomain.com;”
"https://www.youtube.com/embed/" + videoCode + "?version=3&enablejsapi=1&html5=1&rel=0&controls=0&showinfo=0&autoplay=1&mute=1;origin=https://your-domain.com;"
- The second solution was to add the &mute=1 attribute on the url’s attributes. (this one worked for me)
This happens because we are not allowed to autoplay videos with sound on our websites. You have to force the mute option in order for the autoplay to work properly.
I got this issue with Revolution Slider on WordPress. It seems that even though the Revolution slider has an option that says “mute” on/off, it does not add that value to the final link printed out on the iframe.