IT_Programming/JavaScript

오늘 창 안 띄우고 싶을때...

JJun ™ 2007. 2. 13. 12:00

<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.checkClose.Notice.checked)

  {
         setCookie( "notice", "1" , 1);
  }
  self.close();
}
</SCRIPT>

<body>

<br>
<form name="checkClose">
<input type="checkbox" name="Notice">오늘 하루만 이창 띄우지 않기

<center><br><a href=javascript:closeWin()>창닫기</a>
</form>
</body>

/////////////////////////팝업창을 부를 파일/////////////////////////
<script languaage="javascript">
//팝업창 띄우기!!

function cookieVal(cookieName)

{
   thisCookie = document.cookie.split("; ");
   for(i=0; i<thisCookie.length; i++)

   {
      if(cookieName == thisCookie[i].split("=")[0])

      {
          return thisCookie[i].split("=")[1];
      }
   }
   return "x";
}

 

function popup()

{
   if(cookieVal("notice") != "1")

   {
      window.open("popup.htm","notice","height=170, width=200, left=200, top=150");
   }
}

</script>

<body onload=popup();>

 

(출처 : '배너를 만들었는데 '오늘은 창 그만열기'를 추가못하고 있어요.' - 네이버 지식iN)