标签:tran ansi 密码 org tle BMI ofo public cti
<!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"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>用cookie记录上次登录的用户名</title> <script> function setCookie(name,value,iDay){ var oDate=new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie=name+‘=‘+value+‘;expires=‘+oDate; } function getCookie(name){ var arr=document.cookie.split(‘; ‘); for(var i=0;i<arr.length;i++){ var arr2=arr[i].split(‘=‘); if(arr2[0]==name){ return arr2[1]; } } return ‘‘; } function removeCookie(name){ setCookie(name,1,-1); } window.onload=function(){ var oForm=document.getElementById(‘form1‘); var oUser=document.getElementById(‘user‘)[0]; oForm.onsubmit=function(){ setCookie(‘user‘,oUser.value,14); }; oUser.value=getCookie(‘user‘); }; </script> </head> <body> <form id="form1" action="http://www.abc.com/"> 用户名:<input type="text" name="user"/><br/> 密码:<input type="password" name="pass"/><br/> <input type="submit" value="登录"/> </form> </body> </html>
标签:tran ansi 密码 org tle BMI ofo public cti
原文地址:https://www.cnblogs.com/sunnywindycloudy/p/13021454.html