I am experiencing some strange behavior in IE10. I needed to use ActiveXObject to get some files locally (via the file:// protocol).
Why does this work in IE10:
function createXhr() {
return new window.ActiveXObject( "Microsoft.XMLHTTP" );
}
But not this:
function createXhr() {
inMpage = true;
if (inMpage == false) {
var a = new window.XMLHttpRequest();
} else {
var a = new window.ActiveXObject( "Microsoft.XMLHTTP" );
}
return a;
}
Because all modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have a built-in
XMLHttpRequest
object.and your code is executing
else
case which is compatible with old versions of Internet Explorer (IE5 and IE6) not with IE10.To handle all modern browsers, including IE5 and IE6, check if the browser supports the
XMLHttpRequest
object. If it does, create anXMLHttpRequest
object, if not, create anActiveXObject
: