2005/08/12 09:33: Internet Explorer Fix-ups

I see a lot of XMLHttpRequest code that makes a function that handles the request differently for each implementation. Instead, why not just make Internet Explorer behave like the rest? Like so:

if(!window.XMLHttpRequest) { try { var t = new ActiveXObject('Microsoft.XMLHTTP'); XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP'); } } catch(e) { var t = new ActiveXObject('Msxml2.XMLHTTP'); XMLHttpRequest = function() { return new ActiveXObject('Msxml2.XMLHTTP'); } } }

If anyone can think of a more kosher way to see which ActiveX objects are instantiable, I'd love to see it, but this code isn't too inefficient, and you can just write code for the four good browsers and pretend the fifth, evil browser is the same.

Comments