많이 사용하는 하루동안 새 창이 열리지 않게 하는 스크립트 소스입니다.
먼저 메인페이지 index.html 새창을 popup.html 이라고 가정하고 아래 순서대로 하시면 됩니다.
1. index.html 파일의 <head></head> 태그를 찾으세요
2. 아래 자바스크립트 소스를 1번 설명에 맞게 넣으시면 됩니다.
<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('popup.html ','notice','width=300,height=500');
noticeWindow.opener = self;
}
</SCRIPT>
<참고> 바로위에 있는 notice는 팦업창 이름이고 'width=300,height=500'은 팦업창 크기입니다.
3. popup.html 을 만듭니다.popup.html 소스에 아래 자바스크립트를 <head></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>
<참고> 바로위에 있는 setCookie( "Notice", "done" , 1); 에서 1을 7로 수정하면 7일동안 새창 안뜨게 됩니다. 꼭 하루만 다시 안뜨게 할 필요는 없겠죠^^
4. popup.html 의 아래 소스를 <body></body>사이에 넣어줍니다.
"보통 다시열지 않음" 메세지는 하단부분에 있죠^^
<form>
<input type=CHECKBOX name="Notice" value="">하루동안 다시 열지 않음<br><br>
<a href="javascript:history.onclick=closeWin()">닫기</a>
</form>
위 순서대로 하시면 됩니다. 혹 안되시면 덧글 올리세요~~
[이 게시물은 신용성님에 의해 2005-05-27 07:41:13 인터넷창업(으)로 부터 이동됨]
아직 등록된 댓글이 없습니다.
봉끌로드님의 게시글에 첫번째 댓글을 남겨보세요.