XMLHttpRequest对象

创建XMLHttpRequest对象

new ActiveXObject("Microsoft.XMLHTTP");(IE)

new XMLHttpRequest();(非IE版本)

 1 var xmlhttp; 
 2 function createXMLHTTPRequest(){ 
 3     if(window.ActiveXObject){ // 判断是否支持ActiveX控件 
 4         xmlhttp = new ActiveObject("Microsoft.XMLHTTP");
 5     } else if(window.XMLHTTPRequest){
 6         xmlhttp = new XMLHTTPRequest(); 
 7     } 
 8 } 
 9  
10     

区别IE6、IE7、IE8之间的方法: 

 1 var isIE=!!window.ActiveXObject; 
 2 var isIE6=isIE&&!window.XMLHttpRequest; 
 3 var isIE8=isIE&&!!document.documentMode; 
 4 var isIE7=isIE&&!isIE6&&!isIE8; 
 5 if (isIE){ 
 6     if (isIE6){ 
 7         alert(”ie6″); 
 8     }else if (isIE8){ 
 9         alert(”ie8″); 
10     }else if (isIE7){ 
11         alert(”ie7″); 
12     } 
13 }     

 

posted @ 2014-11-05 10:47  一块农田  阅读(111)  评论(0编辑  收藏  举报