检测浏览器是否支持AJAX

 1 <script type="text/javascript"> 

 2 function ajaxFunction() 

 3 { var xmlHttp; 

 4 try { // Firefox, Opera 8.0+, Safari 

 5 xmlHttp=new XMLHttpRequest();

 6  } 

 7 catch (e) 

 8 { // Internet Explorer 

 9 try { 

10 xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

11  } 

12 catch (e) { 

13 try { 

14 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 

15 } catch (e) { 

16 alert("您的浏览器不支持AJAX!"); 

17 return false; 

18 } 

19 } 

20 } 

21 } 

22 </script>

 

你可能感兴趣的:(Ajax)