function init(form)
{
form.idCheck.checked = ((form.userId.value = getCookie("userId")) != "");
}
// 쿠키 조회
function getCookie(userId){
var search = userId + "="
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 saveCookie(form){
var expdate = new Date();
if (form.idCheck.checked){
expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 30); // 30일
}else{
expdate.setTime(expdate.getTime() - 1); // 쿠키 삭제조건
}
setCookie("userId", form.userId.value, expdate);
}
// 쿠키 생성
function setCookie(name, value, expiredays)
{
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + expiredays.toGMTString() ;
}
{
form.idCheck.checked = ((form.userId.value = getCookie("userId")) != "");
}
// 쿠키 조회
function getCookie(userId){
var search = userId + "="
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 saveCookie(form){
var expdate = new Date();
if (form.idCheck.checked){
expdate.setTime(expdate.getTime() + 1000 * 3600 * 24 * 30); // 30일
}else{
expdate.setTime(expdate.getTime() - 1); // 쿠키 삭제조건
}
setCookie("userId", form.userId.value, expdate);
}
// 쿠키 생성
function setCookie(name, value, expiredays)
{
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + expiredays.toGMTString() ;
}
'Java script' 카테고리의 다른 글
프린터하기 (0) | 2010.02.22 |
---|---|
인풋박스 클릭할때 무조건 한글로 설정하기 (0) | 2010.02.12 |
자바스크립트에서 replace (0) | 2009.12.06 |
자바스크립트용 공백제거 (0) | 2009.12.04 |
좌우이동하는 셀렉트박스에서 값 가져오기 (0) | 2009.11.30 |