<%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <head> <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> <title></title> <link href="./pages/ipic/css/main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="./pages/ipic/scripts/login.js"></script> <style type="text/css"> <!-- body { margin: 0px auto; background-image: url(./pages/ipic/images/bg.jpg); text-align: center; background-repeat: repeat-x; background-color: #FFF;} .foot { color: #666;} --> </style> <script type="text/javascript"> function onLoginLoaded(){ if(isPostBack == "False") { GetLastUser(); } } function GetLastUser() { var id = "49BAC005-7D5B-4231-8CEA-16939BEACD67"; var usr = GetCookie(id); if(usr != null) { document.getElementById('username').value = usr; }else { document.getElementById('username').value = "001"; } GetPwdAndChk(); } function SetPwdAndChk() { var usr = document.getElementById('username').value; SetLastUser(usr); if(document.getElementById('chkRememberPwd').checked == true) { var pwd = document.getElementById('password').value; var expdate = new Date(); expdate.setTime(expdate.getTime() + 14 * (24 * 60 * 60 * 1000)); SetCookie(usr,pwd, expdate); }else{ ResetCookie(); } } function SetLastUser(usr) { var id = "49BAC005-7D5B-4231-8CEA-16939BEACD67"; var expdate = new Date(); expdate.setTime(expdate.getTime() + 14 * (24 * 60 * 60 * 1000)); SetCookie(id, usr, expdate); } function GetPwdAndChk() { var usr = document.getElementById('username').value; var pwd = GetCookie(usr); if(pwd != null) { document.getElementById('chkRememberPwd').checked = true; document.getElementById('password').value = pwd; } else { document.getElementById('chkRememberPwd').checked = false; document.getElementById('password').value = ""; } } function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; //alert(j); if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var isPostBack = "true"; function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function SetCookie(name, value, expires) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function ResetCookie() { var usr = document.getElementById('username').value; var expdate = new Date(); SetCookie(usr, null, expdate); } </script> </head> <body onload="onLoginLoaded();"> <form id="form1" action="./login.do?method=login" method="post"> <table width="1010" border="0" cellpadding="0" cellspacing="0"> <tr> <td><table width="1010" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="322"><img src="./pages/sata/images/login_12_01.jpg" width="322" height="85" alt="" /></td> <td width="322"><img src="./pages/sata/images/login_12_02.jpg" width="322" height="85" alt="" /></td> <td width="252"><img src="./pages/sata/images/login_12_03.jpg" width="252" height="85" alt="" /></td> <td><img src="./pages/sata/images/login_12_04.jpg" width="114" height="85" alt="" /></td> </tr> </table></td> </tr> <tr> <td><table width="1010" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="322"><img src="./pages/sata/images/login_12_05.jpg" width="322" height="90" alt="" /></td> <td width="322"><img src="./pages/sata/images/login_12_06.jpg" width="322" height="90" alt="" /></td> <td width="252"><img src="./pages/sata/images/login_07.jpg" width="252" height="90" alt="" /></td> <td><img src="./pages/sata/images/login_12_08.jpg" width="114" height="90" alt="" /></td> </tr> </table></td> </tr> <tr> <td><table width="1010" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="322"><img src="./pages/sata/images/login_12_09.jpg" width="322" height="112" alt="" /></td> <td width="322"><img src="./pages/sata/images/login_12_10.jpg" width="322" height="112" alt="" /></td> <td width="252" align="center" background="./pages/sata/images/login_11.jpg"><table width="90%" height="95" border="0" cellpadding="0" cellspacing="0"> <tr> <td><html:errors/></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="40%">用户名:</td> <td width="60%"><input type="text" name="username" value="${loginform.username }" style="height:18px; width: 150px;" onblur="GetPwdAndChk();" onkeydown="javascript:doLogin();"/></td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="40%">密 码:</td> <td width="60%"> <input type="password" name="password" style="height:18px; width: 150px;" onkeydown="javascript:doLogin();"/> </td> </tr> </table></td> </tr> <tr> <td><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <input type="checkbox" name="chkRememberPwd" checked="checked"/>记住密码 </td> </tr> </table></td> </tr> <tr> <td align="center"><table width="164" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="79"><img src="./pages/sata/images/login_butt1.jpg" width="79" height="27" border="0" onmouseover="changeimg(this,'./pages/sata/images/login_butt10.jpg')" onmouseout="changeimg(this,'./pages/sata/images/login_butt1.jpg')" onclick="login()" style="cursor:pointer;"/></td> <td width="6"></td> <td width="79"><img src="./pages/sata/images/login_butt2.jpg" width="79" height="27" border="0" onclick="setN('username','password')" onmouseover="changeimg(this,'./pages/sata/images/login_butt20.jpg')" onmouseout="changeimg(this,'./pages/sata/images/login_butt2.jpg')" style="cursor:pointer;"/></td> <td> </td> </tr> </table></td> </tr> </table></td> <td><img src="./pages/sata/images/login_12_12.jpg" width="114" height="112" alt="" /></td> </tr> </table></td> </tr> </body> </html>
详细解决方案
js读写cookie,保留用户名和密码
热度:437 发布时间:2012-11-04 10:42:42.0
相关解决方案
- 为啥session id 是保存在 客户端的 cookie 里的啊
- java EL Cookie 有关问题
- cookie 在liunx上获取不到
- jsp cookie 封存密码 用浏览器清除cookie 后再刷新发先cookie不空
- cookie 如何保存和获取 剩余时间
- ASP的7个对象Session、Application、Cookie、Response、Request、Server不知是什么意思,经常混,如何用,多谢
- session 和 cookie 的有关问题
- Session Cookie without Secure flag set,该怎么解决
- Application/Session/ViewState/Cache/cookie 这几个对象可以存储的最大长度是多少,默认是多少?解决方案
- asp.net cookie 中文乱码解决方法
- 高分放送-求asp.net cookie 中文乱码有关问题
- 菜鸟 问一下 Cookie 和Session的有关问题
- cookie 为什么总也不过期解决方法
- 请问 cookie 跨域有关问题
- 请问:cookie 紧急有关问题
- 郁闷死了,登陆有关问题. cookie
- 告诉小弟我什么原因 COOKIE 有关问题
- 如果不设置 COOKIE 有效时间。那么他将与浏览器一直存在,除非关闭浏览器才失效?解决思路
- form 认证 cookie 永久保留有关问题
- 解释一下jquery.cookie 属性解决思路
- 请问Javascript专家,怎么翻译:messing around with cookie
- cookie 鍜宻ession 鐨勫尯鍒??瑙
- jsp cookie
- jquery.cookie 在事件中无效,该如何解决
- IE 火狐狸 谷歌 缓存 cookie
- cookie 实现一个IP一天投5次票,以下代码小弟我写的是只投一次求高手修改
- Htmlunit / HttpClient 报 Cookie rejected 警告 的解决方案
- 对象不支持此属性或方法: 'Request.Cookie'解决办法
- COOKIE 保存域有关问题
- cookie session都过时了,现在是HTML5年代