Search code examples
internet-explorer-9postmessagedailymotion-api

dailymotion API postMessage error with IE9


I want to use the dailymotion player API and post messages don't work with ie9 (windows 7).

var dmplayer = document.getElementById("dmplayer");
var source = null;
var origin = null;
var postMessageListener = function (e) {
    if(source == null && (e.origin === "http://www.dailymotion.com" || e.origin === "https://www.dailymotion.com")){
        source = e.source;
        origin = e.origin;
    }
};        
window.attachEvent("onmessage", postMessageListener); //ie9 only
<iframe style="position:absolute;height:100%;width:100%;top:0;left:0;padding:0;margin:0;" src="http://www.dailymotion.com/embed/video/x2m8jpp?api=1&wmode=opaque" id="dmplayer" width="100%" height="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

When I run source.postMessage('play', origin) I get this error :

Object doesn't support property or method 'apply' x2m8jpp?api=1&wmode=opaque, line 1 character 1

Does anyone have a solution?

Thanks.


Solution

  • Already fixed here : https://github.com/dailymotion/dailymotion-sdk-js/commit/0f5d595aa51b00fc7c4e13497505c4a0d1a902c2

    Please try with latest sdk version