求助,这段代码在网上抄的!怎么我拿来就用不了了!请各位前辈指点!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>未命名</title>
<link href="tyle.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var http_request=false;
function send_request(url){//初始化,指定处理函数,发送请求的函数
http_request=false;
//开始初始化XMLHttpRequest对象
if(window.XMLHttpRequest){//Mozilla浏览器
http_request=new XMLHttpRequest();
if(http_request.overrideMimeType){//设置MIME类别
http_request.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject){//IE浏览器
try{
http_request=new ActiveXObject("Msxml2.XMLHttp");
}catch(e){
try{
http_request=new ActiveXobject("Microsoft.XMLHttp");
}catch(e){}
}
}
if(!http_request){//异常,创建对象实例失败
window.alert("创建XMLHttp对象失败!");
return false;
}
http_request.onreadystatechange=processrequest;
//确定发送请求方式,URL,及是否同步执行下段代码
http_request.open("GET",url,true);
http_request.send(null);
}
//处理返回信息的函数
function processrequest(){
if(http_request.readyState==4){//判断对象状态
if(http_request.status==200){//信息已成功返回,开始处理信息
document.getElementById(reobj).innerHTML=http_request.responseText;
}
else{//页面不正常
alert("您所请求的页面不正常!");
}
}
}
function usercheck(obj){
var f=document.reg;
var newuser=f.newuser.value; ----------------------->提示说50行错误,"newuser"为空或不是对象.
if(newuser==""){
document.getElementById(obj).innerHTML=" <font color=red>用户名不能为空!</font>";
f.newuser.focus();
return false;
}
else{
document.getElementById(obj).innerHTML="正在读取数据...";
send_request('../include/reguser.php?newusername='+newuser);
reobj=obj;
}
}
</script>
</head>
<body>
<form action="/pp/new.php?id=245" method="POST" name="temp_account" id="temp_account">
<table width="526" border="0" align="center" cellpadding="1">
<tr>
<td width="71">用户名:</td>
<td width="210"><input name="newuser" type="text" id="newuser" size="30" maxlength="50" onChange="usercheck('disuserinfo')" onBlur="usercheck('disuserinfo')">
</td>
<td align="left" bgcolor="#FFFFFF" id="disuserinfo">请输入一个用户名!</td>
</tr>
<tr>
</table>
<input name="MM_aaa" type="hidden" id="MM_aaa" value="temp_account">
</form>
</body>
</html>
[此贴子已经被作者于2007-7-2 23:00:36编辑过]