Javascript addEventListener onStateChange not working in IE
IE doesn't support addEventListener
does it?? You need attachEvent
right?
if (el.addEventListener){
el.addEventListener('click', modifyText, false);
else if (el.attachEvent){
el.attachEvent('onclick', modifyText);
}
from testing in IE it looks like the reference you are using
ytswf = document.getElementById('ytplayer1');
is assigned before the actual swf object is loaded, so IE thinks you are referring to a simple div element
you need to run this code
function onYouTubePlayerReady(playerId) {
ytswf = document.getElementById("ytplayer1");
ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}
right after you call
swfobject.embedSWF("http://www.youtube.com/v/SPWU-EiulRY?
hl=en_US&hd=0&rel=0&fs=1&autoplay=1&enablejsapi=1&playerapiid=ytvideo1",
"popupVideoContainer1", "853", "505", "8", null, null, params, atts);
before you close out that $(function()
and place var ytswf;
right after the <script>
instead of further down