<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="md5.js" type="text/javascript" charset="utf-8"></script>
<script src="public.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<label for="">用户名:</label><input type="text" /><br />
<label for="">密 码:</label><input type="password" /><br />
<input type="checkbox"/>记住用户名和密码<br />
<input type="button" value="登录" />
<script type="text/javascript">
var aInput=document.getElementsByTagName('input');
if(getCookie('username') && getCookie('password')){
aInput[0].value=getCookie('username');
aInput[1].value=getCookie('password');
aInput[2].checked=true;
}
aInput[3].onclick=function(){
//alert(getCookie('sex'));//undefined:如果cookie值不存在输出undefined
if(aInput[2].checked){
addCookie('username',aInput[0].value,7);
addCookie('password',hex_md5(aInput[1].value),7);
}else{
delCookie('username');
delcookie('password');
}
}
</script>
</body>
</html>