检测浏览器是否支持ajax ===小代码

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>检测浏览器是否支持ajax</title>

<script type="text/javascript">
var xmlHttp;  
 try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
 catch (e)
  {

  // Internet Explorer
  try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {

  try
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  catch (e)
  {
  alert("您的浏览器不支持AJAX!");
  return false;
  }
  }
  }
</script>
</head>
<body>
ggggggggggg
</body>
</html>
posted @ 2011-05-28 11:22  小2010  阅读(279)  评论(0编辑  收藏  举报