標籤:擷取xmlhttprequest對象
/**
* 擷取XmlHttpRequest對象
*/
function getXMLHttpRequest(){
var xmlHttpReq;
try{ // Firefox, Opera 8.0+, Safari
xmlHttpReq=new XMLHttpRequest();
}
catch (e){
try{// Internet Explorer
xmlHttpReq=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return xmlHttpReq;
}
/**
* 擷取XmlHttpRequest對象
*/
function getXMLHttpRequest(){
var xmlHttpReq=null;
if (window.ActiveXObject) {//IE瀏覽器建立XMLHttpRequest對象
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
}else if(window.XMLHttpRequest){
xmlHttpReq = new XMLHttpRequest();
}
return xmlHttpReq;
}
/**
* 擷取XmlHttpRequest對象
*/
function getXMLHttpRequest() {
var xmlHttpReq=null;
if (window.XMLHttpRequest) {//Mozilla 瀏覽器
xmlHttpReq = new XMLHttpRequest();
}else {
if (window.ActiveXObject) {//IE 瀏覽器
try {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {
try {//IE 瀏覽器
xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
}
}
}
}
return xmlHttpReq;
}
本文出自 “素顏” 部落格,請務必保留此出處http://suyanzhu.blog.51cto.com/8050189/1896875
擷取xmlhttprequest對象