JS 캡슐화 쿠키

11394 단어 cookie
/* @     <www.farwish.com> */
<
script> // cookie: cookie ,cookie , function setCookie(name, value, iDay) {   var oDate = new Data();   oDate.setDate(oDate.getDate() + iDay);   document.cookie = name+ '=' +value+ '; expires = '+oDate } // cookie function getCookie(name) {   var arr = document.cookie.split(; ); // cookie   for(var i = 0; i < arr.length; i++)   {    var arr2 = arr[i].split('='); //     if(arr2[0] == name)     {      return arr2[1]; // cookie cookie     }   }   return ''; // } // cookie function removeCookie(name) {  setCookie(name, 1, -1); } // window.onload = function () {   var oForm = document.getElementById('form');   var oUser = document.getElementsByName('user')[0];   oForm.onsubmit = function ()   {    setCookie('user', oUser.value, 14); // cookie   }   oUser.value = getCookie('user'); // user } </script> <form id="form" action="http://www.chenwei.ws">    :<input type="text" name="user" /><br />    :<input type="password" name="pass" /><br />   <input type="submit" value=" "> </form>

좋은 웹페이지 즐겨찾기