본문 바로가기

DEV/HTML

오늘 하루 그만 보기

반응형

쿠키 설정 (팝업으로 열릴 페이지에 설정)

function SetCookie() {
 today  = new Date();
 todays = new Date();
 Year   = today.getYear();
 Month  = today.getMonth();
 Date   = today.getDate();

 todays.setYear(Year);
 todays.setMonth(Month);
 todays.setDate(Date);
 todays.setHours(32);
 todays.setMinutes(59);
 todays.setSeconds(59);

 document.cookie = "Cookie=Cookie;path=/;expires=" + todays.toGMTString();
 
 self.close();
}


여는 페이지에서 설정된 쿠키가 있는 지 확인 (팝업 열기 전 페이지에서 설정)

function GetCookie(NameCookie) {
 var i = document.cookie.indexOf(NameCookie + '=' );
 if (i != -1) {
  i += NameCookie.length + 1;
  NameEnd = document.cookie.indexOf(';', i);
  if (NameEnd == -1) {
    NameEnd = document.cookie.length;
  }
   return  unescape(document.cookie.substring(i, NameEnd));
   } else {
   return "";
   }
}

function OpenPopup(){
 if( GetCookie("Cookie") != "Cookie" ){
   
//페이지 오픈
 }
}

반응형

'DEV > HTML' 카테고리의 다른 글

Page Refresh  (1) 2011.03.30
[JAVA]TXT 파일 인코딩 설정하여 열기  (1) 2011.03.11
form target  (0) 2011.01.26
글자수제한 스크립트  (0) 2010.09.28
HTML 색상표  (0) 2010.04.19
댓글