본문 바로가기

Programming/JavaScript

팝업창 하루만열기....

============================================
호출페이지
============================================
<SCRIPT LANGUAGE="JavaScript">
<!--
 function get_cookie(name)
 {
  var x    = 0;
  var nameOfCookie = name + "=";
  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 go_event_popup()
 {
   if (get_cookie("event_popup") != "ok")
   {
    noticeWindow =window.open('/common/popup/popup_event_eng.html','notice3','toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=370');
    noticeWindow.opener = self;
   }
 }
//-->
</SCRIPT>
</head>

호출 함수 ==> go_event_popup();

============================================
호출된 팝업창
============================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Speed Book</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<link href="/include/css/default2.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/include/js/common.js"></script>
<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 close_popup()
 {
  setCookie("event_popup, "ok" , 1); //1은 하루동안 쿠키보관, 테스트시 팝업을 새로 열려면 -5로 설정
  self.close();
 }

 window.moveTo(0,0);

// -->
</SCRIPT>
</head>

<body leftmargin="0" topmargin="0" bottommargin="0" rightmargin="0" onLoad="javascript:popup_size_onload(400,450);">
<table width="400" height="450" cellspacing="0" cellpadding="0" border="0" background="http://images.speedbook.co.kr/images2/event/popup_event_eng.jpg">
  <tr>
    <td height="430" colspan="3" align="right" valign="bottom" class="bpad7"><a onClick="close_popup();top.opener.parent.location.href='/board/?menu_id=64'" style="cursor:hand"><img src="http://images.speedbook.co.kr/images2/main3/bt.gif" width="100" height="45" hspace="27" vspace="3"></a><br><a onClick="close_popup();top.opener.parent.location.href='/board/?action=view&menu_id=41&no=86589'" style="cursor:hand"><img src="http://images.speedbook.co.kr/images2/main3/bt.gif" width="100" height="45" hspace="27" vspace="3"></a></td>
  </tr>
  <tr>
    <td width="124" height="20"></td>
    <td width="151" onClick="close_popup();" style="cursor:hand"></td>
    <td width="125"></td>
  </tr>
</table>

</body>
</html>