So, this is definatly one of the worst times i ever had with javascript and the blatent incompitancy of IE, below is my code, i realise that IE does not know of "addEventListener" although support was surpossed to be added in IE9 which still does not work, i have tried every fix i can think of and done all the research i can do on something that should just work anyway.
The function "onYouTubePlayerReady" does not get fired by IE for some(no) reason.Code:google.load("swfobject", "2.1"); var fired = 0; $(document).ready(function(){ track(getQueryString()["vid"]); }); function getQueryString() { var result = {}, queryString = location.search.substring(1), re = /([^&=]+)=([^&]*)/g, m; while (m = re.exec(queryString)) { result[decodeURIComponent(m[1])] = decodeURIComponent(m[2]); } return result; } function track (vid) { var params = { allowScriptAccess: "always" }; var atts = { id: "player" }; var urlString = "http://www.youtube.com/v/" + vid + "&enablejsapi=1&playerapiid=ytplayer"; swfobject.embedSWF(urlString, "embed", "640", "390", "10", "8", null, null, params, atts); } function onYouTubePlayerReady(playerId){ var player = document.getElementById("embed"); player.addEventListener('onStateChange', 'onytplayerStateChange'); } function onytplayerStateChange(newState){ if(newState != -1 && newState != 5 && !fired){ fired = 1; var trackingPixel = new Image(); trackingPixel.src = getQueryString()["unloadUrl"]; } }
There are many threads on this issue but none seem resolved.
See it in action here: http://www.the7thchamber.com/swarm-e...id=jGUADHvbiC8
Thanks for any help, this has been a very trying time for me, sometimes i love javascript but IE forces me to hate it, nothing like spending 30mins coding something then 4 hours making it work in IE.
Cheers,
Nick



Reply With Quote
Bookmarks