Html代码: 复制代码 代码如下: Untitled Document UserName: Password: Js代码: 复制代码 代码如下: <BR>function setCookie(name, value, expires, path, domain, secure) { <BR>var curcookie = name + "=" + encodeURI(value) <BR>+((expires) ? ";expires=" + expires.toGMTString() : "") <BR>+((path) ? ";path=" + path : "") <BR>+((domain) ? ";domain=" + domain : "") <BR>+((secure) ? ";secure" : ""); <BR>document.cookie = curcookie; <BR>} <br><br>function getCookie(name) { <BR>if(document.cookie.length > 0) { <BR>start = document.cookie.indexOf(name + "="); <BR>if( start != -1) { <BR>start = start + name.length + 1; <BR>end = document.cookie.indexOf(";",start); <BR>if( end == -1) { <BR>end = document.cookie.length; <BR>} <BR>} <BR>return decodeURI(document.cookie.substring(start,end)); <BR>} <BR>return ""; <BR>} <br><br>function loginCheck() { <BR>var name = document.frm1.username.value; <BR>var pass = document.frm1.password.value; <BR>if( name == "zghlx" && pass == "123" ) { <BR>var login = true; <BR>var now = new Date(); <BR>now.setDate( now.getDate() + 30); <BR>setCookie("login",login,now); <BR>window.location.href = "index.html"; <BR>} <BR>} <br><br>function userlogin() { <BR>var login = getCookie("login"); <BR>if ( login != null && login != "" ) { <BR>alert("Welcome..."); <BR>window.location.href = "index.html"; <BR>} <BR>} <br><br>userlogin(); <BR>