스크립트태그는 head태그내에 들어가는게 정석입니다.

예)

 <head>

<title>제목</title>

<script>

...

</script>

</head>


팝업창을 띄울 부모 페이지에 들어갈 스크립트


<script language="javascript">
 
function getCookie(name) {
  var Found = false
  var start, end
  var i = 0
 
  while(i <= document.cookie.length) {
    start = i
    end = start + name.length
 
    if(document.cookie.substring(start, end) == name) {
      Found = true
      break
    }
    i++
  }
 
  if(Found == true) {
    start = end + 1
    end = document.cookie.indexOf(";", start)
      if(end < start)
        end = document.cookie.length
    return document.cookie.substring(start, end)
  }
  return ""
}
 
function openPopup()
{
var noticeCookie=getCookie("news1");  // 쿠키변수 이름
if (noticeCookie != "no")
window.open('popup1.htm','pop1','width=350,height=400,top=50,left=150');
// window.open('팝업창 웹페이지','윈도우명','width=350,height=400,top=50,left=150');
}
openPopup();  //팝업 띄우기

</SCRIPT>



팝업으로 보여줄 페이지의 파일명은 노란 형광색칠한 부분과 같은 이름이어야 겠죠.

그리고 파란 형광색칠한 부분도 검사할 쿠키변수명으로 저장할 때와 검사할 때 같은 이름으로 해야겠죠.

그다음에 빨간 형광색칠된 숫자는 원하는 기간을 입력하시면 됩니다. 현재 7로 되어있죠.

popup1.htm


<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 )  // 폼네임 cnjform 은 동일해야 합니다.
    setCookie("news1", "no" , 7);   // 부모창에서 지정한 쿠키네임과 일치 해야 합니다.
  top.close();
}
</script>


<body>

<form name="cnjform">
<input type="checkbox" name="notice" checked>체크하면 한동안(?) 페이지를 열지 않습니다. <br>
<center><input type="button" value="창닫기" onClick="closeWin()"></center>
</form>

</body>





http://kin.naver.com/db/detail.php?d1id=1&dir_id=10105&eid=g1GH2OLG7gJThXJvV2u2PcYONmhY4xe3&qb=xsu+98OiIMfPt+e4uA==

Posted by 귀찮은 여니씨
,