首页 > 代码库 > 简单使用cookie记住密码
简单使用cookie记住密码
加上这个函数:
<SCRIPT LANGUAGE="JavaScript">
function getCookiesPWD() {
document.subform.pwd.style.color=‘#000‘
var password = "";
var cookies = document.cookie.split(";");
//cookies=request.getCookies();
if(cookies!=null){
for(i=0;i<cookies.length;i++){
var aCrumb = cookies[i].split("=");
if ("cookie_tgt" == aCrumb[0])
password = unescape(aCrumb[1]);
document.subform.pwd.value = http://www.mamicode.com/password;
}
}
}
</script>
表单调用:
<form name="subform" action="loginResult" method="post">
<br/>
<div align="center"><input type="text" name="pwd" value="http://www.mamicode.com/密码" onclick="getCookiesPWD()" onFocus="getCookiesPWD()" onBlur="if(!value){value=http://www.mamicode.com/defaultValue;this.style.color=‘#999‘}" style="color:#999; width:200px; height:30px"/></div>
<br/><div align="center"><input type="submit" name="submit" id="btn" value="http://www.mamicode.com/登录"></div>
</form>
简单使用cookie记住密码