예상 시나리오.
[부모.html]에서 팝업관련 쿠기 확인 후
생성안되어있을 경우 [팝업.html] 노출
노출시
[팝업.html]에서 체크박스 선택시 1주일짜리 쿠키생성 및 팝업종료
쿠키생성 (팝업.html)
function setCookie(name, value, expiredays){ var todayDate = new Date(); todayDate.setDate(todayDate.getDate() + expiredays); document.cookie=name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";" }
name: 쿠키이름
value: 쿠키내용
expiredays : 쿠키유효기간(단위 : day)
쿠키확인 (부모.html)
function openPop(){ if(getCookie("cookiename")!="cookievalue"){ window.open('notice.html','안내','left=550, top=5, width=442, height=420, status=no, scrollbars=no, resizeable=no'); } }
function getCookie(name){ var nameOfCookie = name + "="; var x =0; while (x<=document.cookie.length){ var y = (x+nameOfCookie.length); if(document.cookie.substring(x,y) == nameOfCookie){ if((endOfCookie=document.cookie.indexOf(";",y))==-1) endOfCookie = document.cookie.length; return unescape(document.cookie.substring(y, endOfCookie)); } x=document.cookie.indexOf(" ",x) +1; if(x==0) break; } return ""; }
</script> </head> <body onLoad="openPop()"> .. ..
팝업종료 (팝업.html)
javascript:self.close();
댓글
댓글 쓰기