HTML and CSS Reference
In-Depth Information
created in the defacto standards mode versus the ActiveXObject in Internet
Explorer.
Listing 12.5 Instantiating the XMLHttpRequest object
// Proposed standard / works in most browsers
var request = new XMLHttpRequest();
// Internet Explorer 5, 5.5 and 6 (also available in IE 7)
try {
var request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("ActiveX is disabled");
}
Internet Explorer 7 was the first Microsoft browser to provide a quasi-native
XMLHttpRequest object, although it also provides the ActiveX object. Both
ActiveX and IE7's native object can be disabled by users or system administra-
tors though, so we need to be careful when creating the request. Additionally, the
“native” version in IE7 is unable to make local file requests, so we will prefer the
ActiveX object if it's available.
The ActiveX object identificator, “Microsoft.XMLHTTP” in Listing 12.5,
is known as an ActiveX ProgId. There are several available ProgId's for the
XMLHttpRequest object, corresponding to different versions of Msxml:
Microsoft.XMLHTTP
Msxml2.XMLHTTP
Msxml2.XMLHTTP.3.0
Msxml2.XMLHTTP.4.0
Msxml2.XMLHTTP.5.0
Msxml2.XMLHTTP.6.0
In short, Microsoft.XMLHTTP covers IE5.x on older versions of Win-
dows, versions 4 and 5 are not intended for browser use, and the three first
ProgId's will in most setups refer to the same object— Msxml2.XMLHTTP.3.0 .
Finally, some clients may have Msxml2.XMLHTTP.6.0 installed side-by-side
with Msxml2.XMLHTTP.3.0 (which comes with IE 6). This means that ei-
ther Msxml2.XMLHTTP.6.0 or Microsoft.XMLHTTP is sufficient to re-
trieve the newest available object in Internet Explorer. Keeping things simple,
 
Search WWH ::




Custom Search