새창뛰우는 창의헤드부분에 삽입.(본페이지)
<script language="javascript">
//쿠키값을 가져오는 함수
function getCookie(name) {
   var from_idx = document.cookie.indexOf(name+'=');
   if (from_idx != -1) {
      from_idx += name.length + 1
      to_idx = document.cookie.indexOf(';', from_idx)

      if (to_idx == -1) {
            to_idx = document.cookie.length
      }
      return unescape(document.cookie.substring(from_idx, to_idx))
   }
}

//getCookie 함수를 호출하여 쿠키값을 가져온다.
var blnCookie = getCookie("member_gender");
//쿠키값이 true가 아닐 경우에만 새 창을 띄운다.
if ( !blnCookie ) {
   window.open('cook.html','_blink','width=225,height=250,scrollbars=no,toolbar=no,left=0,top=0');                
}
</script>
---------여기까지------

새창에 들어갈 소스(cook.html)
<html>

<head>

<script language="javascript">
//쿠키 생성 함수
function setCookie(name, value, expire) {
    var expire_date = new Date(expire)
    document.cookie = name + "=" + escape(value) + "; expires=" + expire_date.toGMTString();
}

//쿠키 소멸 함수
function clearCookie(name) {
    var today = new Date()
    //어제 날짜를 쿠키 소멸 날짜로 설정한다.
    var expire_date = new Date(today.getTime() - 60*60*24*1000)
    document.cookie = name + "= " + "; expires=" + expire_date.toGMTString()
}

//체크 상태에 따라 쿠키 생성과 소멸을 제어하는 함수
function controlCookie(elemnt) {
        if (elemnt.checked) {
                //체크 박스를 선택했을 경우 쿠키 생성 함수 호출
                setCookie("member_gender","true","July 18, 2010 00:00:00")
                //setTimeout("self.close()");
        }
        else {
                //체크 박스를 해제했을 경우 쿠키 소멸 함수 호출
                clearCookie("member_gender")
        }
        return
}
</script>

</head>

<body>
<p>
<form>
<A onclick="javascript:document.all.closeEvent.checked=true;closeWin();window.opener.document.location.href='event.html';" href="#None">
<IMG src="event.gif" border=0>
</A>
<input type="checkbox" name="closeEvent" onClick="controlCookie(this)">다시는 이창 열지 않기    
<input type="button" value="닫기" onclick='self.close();'><br>
</form>

</body>

</html>

-----여기까지
Posted by 알 수 없는 사용자
,