cookie
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> //设置cookie; function setCookie(name,value,iDay){ var oDate=new Date(); oDate.setDate(oDate.getDate()+iDay); document.cookie=name+'='+value+';expires'+oDate; } //获得cookie; 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("frm1"); var oUser=document.getElementsByName('user')[0]; oForm.onsubmit=function(){ setCookie('user',oUser.value,14); }; }; </script> </head> <body> <form id="frm1" action="http://www.simon.com/"> 用户名:<input type="text" name="user"/><br> 密码:<input type="password"name="pass"/><br> <input type="submit" value="登录"/> </form> </body> </html>