1. 먼저, 새창을 띄울 페이지의 <html>과 </html> 사이에 다음 소스를 삽입합니다.
function getCookie(name) {
var Found = false
var start, end
var i = 0
while(i <= document.cookie.length) {
start = i
end = start + name.length
if(document.cookie.substring(start, end) == name) {
Found = true
break
}
i++
}
if(Found == true) {
start = end + 1
end = document.cookie.indexOf(";", start)
if(end < start)
end = document.cookie.length
return document.cookie.substring(start, end)
}
return ""
}
// 이부분 까지는 수정할 필요 없습니다.
function openPopup()
{
var noticeCookie=getCookie("CookieName"); // 쿠키네임 지정(아무거나 영어로)
if (noticeCookie != "no")
window.open('팝업창 웹페이지 주소','팝업창 이름','width=350,height=400,top=50,left=150');
}
openPopup();
</SCRIPT>
2. 다음에는 팝업될 창의 <head>와</head> 사이에 다음의 소스를 삽입합니다.
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.cnjform.notice.checked ) // 폼네임 cnjform 은 동일해야 합니다.
setCookie("CookieName", "no" , 1); // 위에서 지정한 쿠키네임과 일치 해야 합니다.
}
top.close();
}
</script>
3. 그리고 팝업될 창의 <body>와 </body> 사이에 다음의 소스를 삽입합니다.
<table border="1" cellspacing="0" width="276" bordercolor="#FCB0D8" bordercolordark="white" bordercolorlight="#66CCFF">
<tr>
<td width="270" height="25" bgcolor="#FFE6F2">
<p align="center"><span style="font-size:9pt;"><img src="1202.gif" align="absmiddle" width="30" height="17" border="0">
<font color="red"><b> 공지사항 </b></font><img src="1202.gif" align="absmiddle" width="30" height="17" border="0"></span></p>
</td>
</tr>
<tr>
<td width="270" height="259">
<p align="center"><span style="font-size:9pt;">여기다가 공지사항을
<br>쓰시면 됩니다.</span></p>
</td>
</tr> <tr>
<td width="270" height="9" bgcolor="#99CCFF">
<form name="cnjform">
<p align="center"><span style="font-size:9pt;"><input type="checkbox" name="notice" onclick="closeWin()"> 오늘 하룻동안 페이지를 열지 않습니다.</span>
</form>
</td>
</tr>
</table>
'프로그래밍 > 자바스크립트' 카테고리의 다른 글
| 테두리가 둥근 테이블 만들기 (0) | 2008/08/26 |
|---|---|
| 체크시 오늘 하루동안 새창 열지 않기 (0) | 2008/08/25 |
| 링크시 생기는 테두리 한번에 없에는 자바스크립트 (6) | 2008/08/22 |
| 웹사이트 및 블로그에 즐겨찾기추가 버튼 달기(파이어폭스,IE 작동) (1) | 2008/08/21 |



