[新手询问]如何在IE7.0中创建XMLHttpRequest对象?
重返IT路 2009-02-10 11:54:01 function getClient(){
var client = getClientFromOthers();
if(client == null){
client = getClientFromIE();
}
return client
}
function getClientFromOthers(){
var client = null;
try{
return new XMLHttpRequest();
}catch(e){
}
return client;
}
function getClientFromIE(){
var client = null;
try{
if(window.ActiveXObject){
client = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.ActiveXObject){
client = new ActiveXObject("Msxml2.XMLHTTP.4.0");
}
else if(window.ActiveXObject){
client = new ActiveXObject("Msxml2.XMLHTTP");
}
}catch(e){}
return client;
}
本人获得XMLHttpRequest对象是这么写的,但这个对象就是创建不起来