做了个AJAX验证,怎么只认IE,换上别的浏览器就不认,怎么办?
怎么样做能自动判断游览器?
新手上路,请多指教!
我的代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>个人信息查询</title>
<script type="text/javascript">
<!--
function Initxmlhttp_request()
{
var xmlhttp_request=false;
try {
xmlhttp_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp_request = false;
}
}
if (!xmlhttp_request && typeof XMLHttpRequest!='undefined') {
xmlhttp_request = new XMLHttpRequest();
}
return xmlhttp_request;
}
function Onsearch()
{
var sinfo = document.getElementById("sinfo");
var msgs = document.getElementById("msgs");
msgs.innerHTML = "正在搜索...";
var f = document.form1;
var userselects = f.selects.options(f.selects.selectedIndex).value;
var userkeyword = f.keyword.value;
//接收表单的URL地址
var url = "search.php";
//POST的值
var postStr = "selects="+ userselects +"&keyword="+ userkeyword ;
var xmlhttp_request = Initxmlhttp_request();
xmlhttp_request.open("POST", url, true);
xmlhttp_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlhttp_request.send(postStr);
xmlhttp_request.onreadystatechange = function() {
if (xmlhttp_request.readyState == 4 && xmlhttp_request.status == 200) {
msgs.innerHTML = "";
sinfo.innerHTML = xmlhttp_request.responseText;
}
}
}
//-->
</script>
</head>
<body>
<table width="578" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="24" colspan="2" align="center" valign="middle" bgcolor="#4D4D4D">个人信息查询</td>
</tr>
<tr>
<td width="172" height="6" align="center" bgcolor="#202020"></td>
<td width="404" bgcolor="#202020"></td>
</tr>
<tr>
<td height="190" colspan="2" align="center" valign="top"><div id="searchmain">
<div align="left">请选择查询方式并填写查询信息 </div>
<form id="form1" name="form1" method="post" action="">
<label>
<select name="selects" id="selects">
<option value="name">按姓名</option>
<option value="sid">按学号</option>
</select>
<input name="keyword" type="text" id="keyword" />
<input name="Submit" type="button" onclick="Onsearch()" value="查询" />
</label>
</form>
<div id="msgs"></div>
</div>
<div id="sinfo"></div></td>
</tr>
<tr>
<td height="20" colspan="2" align="center" valign="top" ></td>
</tr>
</table>
</body>
</html>