I have two colorbox popups that show YouTube videos. When they finish the game, I try to automatically close the colorbox window. This code below works fine in firefox, but in IE I can't get addEventListener to work. I tried attachEvent without success. Can anyone suggest any suggestions as to how to solve this? It seems simple, but I'm exhausted trying to find a solution. By the way, this is my first time in stackoverflow, and it is very impressive.
UPDATE 1:
Well, this is my current code. It works fine in FF, but IE only gives good results. IE8 debugger also doesn't report errors ...
function onYouTubePlayerReady(playerId) {
if (playerId && playerId != 'undefined') {
if(playerId && playerId == 'ytvideo1'){
var ytswf = document.getElementById('ytplayer1');
alert('good');
} else if(playerId && playerId == 'ytvideo2'){
var ytswf = document.getElementById('ytplayer2');
} else {
}
setInterval('', 1000);
ytswf.addEventListener('onStateChange', 'onytplayerStateChange');
alert('great');
}
}
function onytplayerStateChange(newState) {
alert('amazing');
if(newState == 0){
$.fn.colorbox.close();
alert('perfect');
}
}
Update 3: Solution
onComplete colorbox swfobject , IE.