[팝업 페이지 코드] - 팝업페이지.htm
<head>
...
...
<script language="javascript">
function setCookie(name,value,expiredays) {
var todayDate = new Date();
todayDate.setDate(todayDate.getDate() + expiredays);
document.cookie = name + "=" + escape(value) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function closeWin() {
if(document.noticeForm.openChk.checked)
setCookie('adver','pop1','1');
self.close(); //창 닫기
}
</script>
</head>
<body onUnLoad="closeWin();">
...
...
</body>
</html>
[호출 페이지 코드]
<body onUnLoad="closeWin();">
...
<table width="490" border="0" cellspacing="0" cellpadding="0">
<tr>
<TD height="40">
<INPUT TYPE=checkbox name="openChk">
<font size="2" face="돋움">하루동안 이 창을 띄우지 않음</font>
</TD>
<TD align="right">
<a onclick="closeWin()" style="font-size:10pt; font-weight:bold; color:red; text-decoration: underline; cursor:hand">닫기</a>
</TD>
</tr>
</table>...
</body>
</html>
[호출 페이지 코드]
<head>
<script language="javascript">
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 "";
}
var eventCookie = getCookie("adver");
var win;
if(eventCookie != "pop1") {
win = window.open('팝업페이지.htm', 'Adver', 'width=510, height=320, scrollbars=no');
}
</script>
</head>