JAVASCRIPT

    팝업창 띄우기 (1)
    • 조회수 6,040
    • 작성일 2010-12-31
    •  
    ① 팝업 페이지

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
    <title>하누리 팝업</title>
    <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.cnjform.notice.checked ) {
      setCookie("notice", "no" , 1);
     }
     top.close();
    }
    </script>
    </head>
    <body topmargin="0" leftmargin="0">
    <table width="800" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="../images/popup.jpg" width="800" height="256"></td>
      </tr>
      <tr>
        <td align="right" style="font-size:12px; color:#000000; font-weight:bold">
         <form name="cnjform">
           <input type="checkbox" name="notice" onClick="closeWin()" value="ON"> 오늘 하루 이 페이지를 열지 않습니다.
          </form>
      </td>
       </tr>
    </table>
    </body>
    </html>

    ② 부모 페이지

    <script language="Javascript"> 
    function openPopup() {
     var noticeCookie=getCookie("notice");  // 쿠키네임 지정
     if (noticeCookie != "no") {
      window.open('popup.html','pop1','width=800,height=276,top=0,left=0,scrollbars=no');
     }
    }
    </script> 
    <body topmargin="0" leftmargin="0" onload="openPopup();">