Sunday, January 31, 2010

Pre Initialization Technique

An interesting piece of code which does a pre initialization.

XMLHttpRequest = (function () {
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
catch (e1) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
catch (e2) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e3) {}
try { return new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e4) {}
throw new Error("This browser does not support XMLHttpRequest.");
})();

No comments: