P
Peter Michaux
Instantiating an XMLHttpRequest object in Internet Explorer is a bit
confusing. I have seen all of the following in various places and I
have seen the string argument with various captializations.
new ActiveXObject('Microsoft.XMLHttp')
new ActiveXObject('MSXML2.XMLHttp')
new ActiveXObject('MSXML2.XMLHttp.3.0')
new ActiveXObject('MSXML2.XMLHttp.4.0')
new ActiveXObject('MSXML2.XMLHttp.5.0')
new ActiveXObject('MSXML2.XMLHttp.6.0')
It seems as though ActiveXObject is case insensitive to its argument.
I have looked but cannot find documentation to support this. Does
anyone know where Microsoft states this?
Deciding which argument(s) to try is confusing. Even the Microsoft
people don't agree:
From Microsoft's XML team's blog
<URL: http://blogs.msdn.com/xmlteam/archi...ht-version-of-msxml-in-internet-explorer.aspx>
From Microsoft's IE team blog
<URL: http://blogs.msdn.com/ie/archive/2006/01/23/516393.aspx>
What I gather from the above two pages is the following.
"Microsoft.XMLHTTP" is for legacy. This may be implemented in MSXML3
as a synonym for legacy support. A computer that only has MSXML3
installed will still function. Knowing if the two are synonyms is
important.
"Msxml2.XMLHTTP.2.0" should be avoided???
"Msxml2.XMLHTTP.3.0" and "Msxml2.XMLHTTP" may be synonymous and are on
all OS from fully patched Win2k SP4 and up
"Msxml2.XMLHTTP.4.0" was never released with an OS and completely
superseeded by MSXML6
"Msxml2.XMLHTTP.5.0" is for use with Microsoft Office only
"Msxml2.XMLHTTP.6.0" is the new standard that may have some advantages
over older versions but maybe not for the XHR object.
Testing that a page that uses an ActiveX XHR object requires testing
on a variety of computers that have certain dll files corresponding to
the arguments tried when instantiating the ActiveXObject. Keeping the
number of arguments tried to a minimum reduces the number of dll files
that need to be tested. To determine which dlls are installed on the
computer look in System32 folder to find files like "msxml3.dll"
The IE blog recommends using Microsoft.XMLHTTP and the XML team blog
recommends using MSXML2.XMLHttp.3.0. My guess is the XML team is not
thinking like a browser script programmer that is worried about
backwards compatability.
A page about this by Martin Honnen
<URL: http://www.faqts.com/knowledge_base/view.phtml/aid/35742>
--------------------------------------
The following function would be the maximum function that could be
used if MSXML 4 and 5 should not be used. It doesn't test the
abilities of the XHR but just sets a function that is capable of
instantiating an XHR. A function that will use XHR objects must
determine if XHR in the browser has the necessary set of abilities for
the function. '
var createXMLHttpRequest = (function() {
var xhr,
i,
fs = [// for legacy eg. IE 5
function() {
return new ActiveXObject("Microsoft.XMLHTTP");
},
// for fully patched Win2k SP4 and up
// next line may be useless and just a synonym for
// the Microsoft.XMLHTTP factory above
function() {
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
},
// IE 6 users that have updated their msxml dll files.
function() {
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
},
// IE7, Safari, Mozilla, Opera, etc
function() {
return new XMLHttpRequest();
}];
// Loop through the possible factories to try and find one that
// can instantiate an XMLHttpRequest object that works.
for (i=fs.length; i--; ) {
try {
if (fs()) {
return fs;
}
}
catch (e) {}
}
})();
---------------
The minimum function would be the following
var createXMLHttpRequest = (function() {
var xhr,
i,
fs = [// IE 6-
function() {
return new ActiveXObject("Microsoft.XMLHTTP");
},
// IE7, Safari, Mozilla, Opera, etc
function() {
return new XMLHttpRequest();
}];
// Loop through the possible factories to try and find one that
// can instantiate an XMLHttpRequest object that works.
for (i=fs.length; i--; ) {
try {
if (fs()) {
return fs;
}
}
catch (e) {}
}
})();
Of course both of the above can be included in the repository. What
I'd like to know is if there is any advantage at all by using the
longer version.
confusing. I have seen all of the following in various places and I
have seen the string argument with various captializations.
new ActiveXObject('Microsoft.XMLHttp')
new ActiveXObject('MSXML2.XMLHttp')
new ActiveXObject('MSXML2.XMLHttp.3.0')
new ActiveXObject('MSXML2.XMLHttp.4.0')
new ActiveXObject('MSXML2.XMLHttp.5.0')
new ActiveXObject('MSXML2.XMLHttp.6.0')
It seems as though ActiveXObject is case insensitive to its argument.
I have looked but cannot find documentation to support this. Does
anyone know where Microsoft states this?
Deciding which argument(s) to try is confusing. Even the Microsoft
people don't agree:
From Microsoft's XML team's blog
<URL: http://blogs.msdn.com/xmlteam/archi...ht-version-of-msxml-in-internet-explorer.aspx>
From Microsoft's IE team blog
<URL: http://blogs.msdn.com/ie/archive/2006/01/23/516393.aspx>
What I gather from the above two pages is the following.
"Microsoft.XMLHTTP" is for legacy. This may be implemented in MSXML3
as a synonym for legacy support. A computer that only has MSXML3
installed will still function. Knowing if the two are synonyms is
important.
"Msxml2.XMLHTTP.2.0" should be avoided???
"Msxml2.XMLHTTP.3.0" and "Msxml2.XMLHTTP" may be synonymous and are on
all OS from fully patched Win2k SP4 and up
"Msxml2.XMLHTTP.4.0" was never released with an OS and completely
superseeded by MSXML6
"Msxml2.XMLHTTP.5.0" is for use with Microsoft Office only
"Msxml2.XMLHTTP.6.0" is the new standard that may have some advantages
over older versions but maybe not for the XHR object.
Testing that a page that uses an ActiveX XHR object requires testing
on a variety of computers that have certain dll files corresponding to
the arguments tried when instantiating the ActiveXObject. Keeping the
number of arguments tried to a minimum reduces the number of dll files
that need to be tested. To determine which dlls are installed on the
computer look in System32 folder to find files like "msxml3.dll"
The IE blog recommends using Microsoft.XMLHTTP and the XML team blog
recommends using MSXML2.XMLHttp.3.0. My guess is the XML team is not
thinking like a browser script programmer that is worried about
backwards compatability.
A page about this by Martin Honnen
<URL: http://www.faqts.com/knowledge_base/view.phtml/aid/35742>
--------------------------------------
The following function would be the maximum function that could be
used if MSXML 4 and 5 should not be used. It doesn't test the
abilities of the XHR but just sets a function that is capable of
instantiating an XHR. A function that will use XHR objects must
determine if XHR in the browser has the necessary set of abilities for
the function. '
var createXMLHttpRequest = (function() {
var xhr,
i,
fs = [// for legacy eg. IE 5
function() {
return new ActiveXObject("Microsoft.XMLHTTP");
},
// for fully patched Win2k SP4 and up
// next line may be useless and just a synonym for
// the Microsoft.XMLHTTP factory above
function() {
return new ActiveXObject("Msxml2.XMLHTTP.3.0");
},
// IE 6 users that have updated their msxml dll files.
function() {
return new ActiveXObject("Msxml2.XMLHTTP.6.0");
},
// IE7, Safari, Mozilla, Opera, etc
function() {
return new XMLHttpRequest();
}];
// Loop through the possible factories to try and find one that
// can instantiate an XMLHttpRequest object that works.
for (i=fs.length; i--; ) {
try {
if (fs()) {
return fs;
}
}
catch (e) {}
}
})();
---------------
The minimum function would be the following
var createXMLHttpRequest = (function() {
var xhr,
i,
fs = [// IE 6-
function() {
return new ActiveXObject("Microsoft.XMLHTTP");
},
// IE7, Safari, Mozilla, Opera, etc
function() {
return new XMLHttpRequest();
}];
// Loop through the possible factories to try and find one that
// can instantiate an XMLHttpRequest object that works.
for (i=fs.length; i--; ) {
try {
if (fs()) {
return fs;
}
}
catch (e) {}
}
})();
Of course both of the above can be included in the repository. What
I'd like to know is if there is any advantage at all by using the
longer version.