代 *** 如下:
<html>
<head><title>The Cookie</title>
</head>
<script language="javacript">
function creatCookie(form){
var when=new Date();
when.setTime(when.getTime()+24*60*60*1000);
when.setfullyear(when.getfullyear()+1);
yname=form.yourname.value;
rpasswd=form.passwd.value;
document.cookie=encodeURI("name")+"="+encodeURI(yname)
+";expires="+when.toGMTString();
document.cookie=encodeURI("passwd")+"="+encodeURI(ypasswd)
+";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("Welcome! "+you);
}else{
alert("You don't have a cookie!");
}
}
</script>
<body bgcolor="lightgrey">
会员注册
会员登录
个人空间
发表评论