日期:2014-05-16  浏览次数:20415 次

急急急~~求高手帅男指点啊~
这个程序试了几遍一直都存在错误,但是就是找不到错误在什么地方。。急求高手帮忙,我是初学者,请多多关照,谢谢啦。
这个程序是关于创建cookie和查找cookie。
<html>
<head>
<title>
cookie验证程序
</title>
<script language="JavaScript">
function makecookie(form)
{var when=new Date();
when.setTime(when.getTime()+24*60*60*1000);
when.setFullYear(when.getFullYear()+1);
yname=form.yourname.value;
ypassword=form.yourpassword.value;
document.cookie=encodeURI("name")+"="+encodeURI(yname)+";expires="+when.toGMTString();
document.cookie=encodeURI("password")+"="+encodeURI(ypassword)+";expires="+when.toGMTString();
alert(document.cookie);
}
function welcome(myform)
{you=myform.yourname.value;
  var position=document.cookie.indexOf("name=");
 if (position!=-1)
{var begin=position+5;
 var end=document.cookie.indexOf(";",begin);
 if (end==-1){end=document.cookie.length;}
 you= decodeURI(document.cookie.substring(begin,end));
 str=you;
alert("欢迎"+you);
}
else{alert("你没有cookie");}
}
</script>
</head>
<body bgcoloR="green" onLoad="document.form1.reset()">
<form name="form1">
用户名:
<input type="text" name="yourname">
<p>
密码:
<input type="text" name="yourpassword">
<p>
<input type="button" value="创建cookie" on Click="makecookie(this.form);">
<p>
<input type="button" value="查看cookie" on Click="welcome(this.form);">
<p>
</form>
</body>
</html>

------解决方案--------------------
具体的我也不太明白