본문 바로가기

카테고리 없음

[자바스크립트] [팝업창] 하루동안 팝업창 띄우지 않기 소스 예제2

* 하루동안 팝업창 띄우지 않기 소스 예제2

부모창인 index.htm에 삽입
<html>
<head>
<title>..</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function change(form)
{
if (form.url.selectedIndex !=0)
parent.location = form.url.options[form.url.selectedIndex].value
}
function setCookie( name, value, expiredays )
{
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
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 "";
}
if ( getCookie( "Notice" ) != "done" )
{
noticeWindow = window.open('pop.htm','notice','toolbar=no,location=no,directories=no,status=no,
menubar=no,scrollbars=no, resizable=no,width=400,height=400');
//winddow.open의 ()의 것은 한줄에 계속 붙여써야 오류가 안남, 줄바뀌면 오류남
noticeWindow.opener = self;
}
//-->
</script>
</head>
<body>
</body>
</html>



팝업창인 pop.htm에 삽입
<html>
<head>
<title></title>
<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.forms[0].Notice.checked )
setCookie( "Notice", "done" , 1);
self.close();
}
//-->
</script>
</head>
<body onunload="closeWin()">
<form>
<input type=CHECKBOX name="Notice" value="">다시 팝업 안뜸
<a href="javascript:window.close()">닫기</a>
</form>
</body>
</html>


[출처] 플래시 활용도 높은 소스 Tip 모음|작성자 카제