1

I have a video iframe in my website page for this I am using youtube and vimeo videos and change iframe src on finish video.

My code is :

<script src="http://www.youtube.com/player_api"></script>
<script src="https://f.vimeocdn.com/js/froogaloop2.min.js"></script>
function onYouTubePlayerAPIReady()
{
    player = new YT.Player('video_player', {
        events: {
            'onStateChange': changeVideoSrc,
            'onReady': onPlayerReady
        }
    });

}

function changeVideoSrc()
{
    // here changing the iframe src
}

$('#main iframe').load(function() {
    var iframe = $('#video_player');
    var player = $f(iframe);

    player.addEvent('ready', function() {
        player.addEvent('finish', onFinish);
    });
    function onFinish(id) 
    {
        // here changing the iframe src
    }

});

All are working, but in console there is a error generated on change iframe src that is :

Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('https://player.vimeo.com').

I have also try to add vimeo message event listener but it is not working for me.

How to remove this error from console?

  • Basically, your error means that this might be an issue with the target origin being `https`. Maybe it's because your iFrame url is using `http` instead of `https`. Try changing the url of the file you are trying to embed to be `https`. Check this [link](http://stackoverflow.com/questions/27573017/failed-to-execute-postmessage-on-domwindow-https-www-youtube-com-http). You can also refer on this [thread](http://stackoverflow.com/questions/27882594/failed-to-execute-postmessage-on-domwindow-target-origin-mismatch-http-vs-h). – abielita Sep 27 '16 at 15:37

0 Answers0