获取XmlHttpRequest对象
//1
Funktion pRequest( ) {
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;
}
//2
function getXMLHttpRequest() {
var xmlHttpReq = null;
if (window.ActiveXObject) {// Internet Explorer
xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");
} else if (window.XMLHttpRequest) {
xmlHttpReq = new XMLHttpRequest();
}
return xmlHttpReq;
}
//3
function getXMLHttpRequest() {
var xmlHttpReq = null;
if (window.XMLHttpRequest) {// Mozilla Firefox, Opera 8.0, Safari
xmlHttpReq = new XMLHttpRequest();
} else {
if (window.ActiveXObject) {// Internet Explorer
try {
xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} Catch (e) {
try {// Internet Explorer
xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
} Catch (e) {
}
}
}
}
return xmlHttpReq;
}