做了个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>
新手上路,请多指教!
我的代码如下:
<!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>
...全文
相关推荐
浅析IE浏览器关于ajax的缓存机制
本文将深入探讨IE浏览器关于Ajax缓存机制的原理和如何优化。在默认情况下,IE浏览器会缓存AJAX请求的结果,这意味着对于同一URL,除非缓存过期,否则后续请求通常不会再次发送到服务器,这可能会导致
ajax页面无刷新 IE下遭遇Ajax缓存导致数据不更新的问题
然而,IE浏览器的缓存机制有时会导致Ajax请求的数据不更新,即当Ajax请求相同URL时,浏览器可能会从本地缓存中读取旧数据,而非向服务器发起新的请求。IE浏览器的这种行为主要出现在GET请求中。
IE 浏览器web扫描插件
【IE浏览器web扫描插件】是一种专为IE浏览器设计的扩展功能,旨在提供方便快捷的文档扫描服务。
Ajax 创建XMLHttpRequest对象,兼容所有主流浏览器(IE5除外)
跨浏览器能力非常有限。并不全面。经测试,用此方法创建XMLHttpRequest对象,在运用AJAX的时候,可以的兼容IE6,IE7,IE8
IE兼容性问题的快速解决方法_ajax请求不发送到后台
ajax IE 兼容性问题的解决方法在前端开发中,ajax 是一个非常常用的技术,可以帮助我们实现异步请求,从而提高用户体验。但是,在IE浏览器下,ajax 请求有时候会出现问题,即ajax 请求


