建立XMLHttpRequest对象spa
new ActiveXObject("Microsoft.XMLHTTP");(IE)code
new XMLHttpRequest();(非IE版本)xml
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
区别IE六、IE七、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 }