在IE中,XMLHttpRequest的实现为一个ActiveX控件,该控件的名称在不同的版本中会有所不同,总结起来包括:Microsoft.XMLHTTP、msxml.XMLHTTP、msxm2.XMLHTTP或msxml3.XMLHTTP
function createXMLHttpRequstForIE(){
var nameprefixes=["Msxml","Msxml2","Msxml3","Micosoft"];
for(var i=0;i<nameprefixes.length;i++){
try{
var name=nameprefixes[i]+".XMLHTTP";
return new ActiveObject(name);
}catch(e){
}
}
return null;
}
function createXMLHttpRequstForIE(){
var nameprefixes=["Msxml","Msxml2","Msxml3","Micosoft"];
for(var i=0;i<nameprefixes.length;i++){
try{
var name=nameprefixes[i]+".XMLHTTP";
return new ActiveObject(name);
}catch(e){
}
}
return null;
}