<script>
functioncreateAjax(){
varrequest=false;
//window对象中有XMLHttpRequest存在就是非IE,包括(IE7以上版本)
if(window.XMLHttpRequest){
request=newXMLHttpRequest();
if(request.overrideMimeType){
request.overrideMimeType("text/xml");
}
//window对象中有ActiveXObject属性存在就是IE
}elseif(window.ActiveXObject){
varversions=['Microsoft.XMLHTTP','MSXML.XMLHTTP','Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0','Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP'];
for(vari=0;i<versions.length;i++){
try{
request=newActiveXObject(versions[i]);
if(request){
returnrequest;
}
}catch(e){
request=false;
}
}
}
returnrequest;
}
varajax=createAjax();
alert(ajax);
</script>