首页 > Web开发 > 详细

获取xmlhttprequest对象

时间:2017-02-11 14:50:32      阅读:251      评论:0      收藏:0      [点我收藏+]

/**

 * 获取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对象

原文:http://suyanzhu.blog.51cto.com/8050189/1896875

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!