-2005. 10. 6. 16:36-
<html>
<head>
<script language="javascript">
function setCookie (name, value, expires) {
document.cookie = name + "=" + escape (value) +
"; path=/; expires=" + expires.toGMTString();
}function getCookie(Name) {
var search = Name + "="
if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
offset = document.cookie.indexOf(search)
if (offset != -1) { // 쿠키가 존재하면
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset)
// 쿠키 값의 마지막 위치 인덱스 번호 설정
if (end == -1)
end = document.cookie.length
return unescape(document.cookie.substring(offset, end))
}
}
return "";
}
function saveid(form) {
var expdate = new Date();
// 기본적으로 30일동안 기억하게 함. 일수를 조절하려면 * 30에서 숫자를 조절하면 됨
if (form.checkIdBox.checked)
expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 30); // 30일
else
expdate.setTime(expdate.getTime() - 1); // 쿠키 삭제조건
setCookie("saveid", form.wbUserid.value, expdate);
}
function getid(form) {
form.checkIdBox.checked = ((form.wbUserid.value = getCookie("saveid")) != "");
}
</script>
</head>
<body onLoad="getid(document.mainform)">
<form name=mainform>
아이디 <input type=text name=wbUserid>
암호 <input type=password name=pw>
<input type=checkbox name=checkIdBox onClick="saveid(this.form)">아이디 기억
</form>
</body>
</html>
'자바스크립트' 카테고리의 다른 글
jquery 가이드 (0) | 2023.12.26 |
---|---|
jquery 다운로드 (0) | 2023.12.26 |
자바스크리트 select 이용한 계산 방법 (2) | 2018.12.08 |
자바스크립트 간단한 날짜 및 응용 SELECT 사용 하여 구하기 (0) | 2018.12.08 |
자바스크립트 쿠키인증 받기 (0) | 2018.12.08 |