﻿// JScript 文件
//创建XMLHTTP对象
function newXMLHTTPRequest(){
    var xmlreq=false;
    if (window.XMLHttpRequest){                                 //FireFox支付的XMLHttpRequest对象
        xmlreq= new XMLHttpRequest();
    }else if (window.ActiveXObject) {
        try{
            xmlreq=new ActiveXObject("Msxml2.XMLHTTP");         //IE高版本中创建XMLHTTP对象
        }catch(e1){
            try{
                xmlreq=new ActiveXObject("Microsoft.XMLHTTP");  //IE低版本中创建
            }catch(e2){                                         //都不能创建对象,返回False
            }
        }
    }
    return xmlreq;
}
            
if(!window.attachEvent && window.addEventListener) { //绑定事件函数 ie 用attachEvent， firefox 使用addEventListener；
   Window.prototype.attachEvent = HTMLDocument.prototype.attachEvent= HTMLElement.prototype.attachEvent=function(en, func, cancelBubble) { 
      var cb = cancelBubble ? true : false; 
      this.addEventListener(en.toLowerCase().substr(2), func, cb); 
   }; 
} 

if(!window.detachEvent && window.removeEventListener) { //删除绑定事件函数 ie 用detachEvent， firefox 使用removeEventListener；
   Window.prototype.detachEvent = HTMLDocument.prototype.detachEvent= HTMLElement.prototype.detachEvent=function(en, func, cancelBubble) { 
      var cb = cancelBubble ? true : false; 
      this.removeEventListener(en.toLowerCase().substr(2), func, cb); 
   }; 
}
