그러냐

팝업 오늘하루 이창 열지 않기 본문

javascript

팝업 오늘하루 이창 열지 않기

관절분리 2016. 1. 27. 18:15
반응형

출처 몽땅 사자.. | thdehdgl
원문 http://blog.naver.com/thdehdgl/110034924121
 

 

<html>
<head>
<title> 팝업 </title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<link rel="stylesheet" href="/include/text.css" type="text/css">
<SCRIPT language="JavaScript">
<!--
// 쿠키를 만듭니다. 아래 closeWin() 함수에서 호출됩니다
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.pop.Notice1.checked )
        setCookie( "NEW1", "done" , 1);  // 오른쪽 숫자는 쿠키를 유지할 기간을 설정합니다
        self.close();
}
// -->
</SCRIPT>
</head>
<body text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<form name="pop">
  <table width="600" border="0" cellspacing="0" cellpadding="0" height="350">
    <tr>
      <td valign="top" bgcolor="#000000">팝업입니다.이미지를 거의 넣겠죠.
      </td>
    </tr>
    <tr>
      <td valign="top" bgcolor="#000000"><table width="88%" border="0" align="right" cellpadding="0" cellspacing="0" class="font1">
        <tr>
          <td width="87%" height="23" bgcolor="#000000"><input type="checkbox" name="Notice1" value="">
              <span class="text style1"> <font color="#FFFFFF">오늘 하루 이창을 열지않음</font></span></td>
          <td width="13%" height="23"><a href="javascript:history.onclick=closeWin()"><img src="close.gif" width="46" height="13" border="0"></a></td>
        </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>

 

 

이페이지의 이름은 test_popup.html로 하겠습니다.

--------------여기까지가 팝업.html입니다....오늘 하루 이창을 열지않음 쿠키 set까지 합니다.-------

 

이제 이팝업을 띄울...html을 만듭니다.. 이페이지가 열릴때 저위에 팝업이 뜨겠죠.

 

 

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function notice_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 "";
}

function open_pop() {
if ( notice_getCookie( "NEW1" ) != "done" ) {
window.open('test_popup.html','notice1','width=800,height=415, left=1,top=1');
}

}
</script>
</head>
<body onload="javascript:open_pop()">

</body>
</html>

 

test.html로 저장합니다 같은 폴더에 넣어 놓고 test.html을 클릭해서 열면 팝업이 열립니다.

 

반응형