** cell 팝업 띄우기.
메인의 head사이에는
<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)) } }
var CloseDate = new Date("july 5, 2003"); //팝업 윈도우를 닫고자 하는 날짜를 입력하세요. var Today = new Date(); //오늘 날짜
if (Today < CloseDate) { //getCookie 함수를 호출하여 쿠키값을 가져온다. var blnCookie = getCookie("op1"); //쿠키값이 true가 아닐 경우에만 새 창을 띄운다. if ( !blnCookie ) { win = window.open("event_p.html","op1","width=300,height=440"); win.focus(); } } //--> </script>
팝업창 head사이에는 ① , ② 를 넣는다. ① <script language="JavaScript"> <!-- function win_link(url_link) { window.opener.location=url_link; window.close() } --> </script> → 이 스크립트는 팝업창의 링크를 클릭했을때 팝업창이 닫히면서 메인(본)창에 링크된 페이지가 뜨는것.
② <script language="JavaScript"> <!-- //설정한 날짜만큼 쿠키가 유지되게. expiredays가 1 이면 하루동안 유지 function setCookie(name, value, expiredays) { var expire_date = new Date(); expire_date.setDate(expire_date.getDate() + expiredays ); document.cookie = name + "=" + escape( value ) + "; expires=" + expire_date.toGMTString() + "; path=/"; } //쿠키 소멸 함수 function clearCookie(name) { var expire_date = new Date(); //어제 날짜를 쿠키 소멸 날짜로 설정한다. expire_date.setDate(expire_date.getDate() - 1) document.cookie = name + "= " + "; expires=" + expire_date.toGMTString() + "; path=/" }
//체크 상태에 따라 쿠키 생성과 소멸을 제어하는 함수 function controlCookie(elemnt) { if (elemnt.checked) { //체크 박스를 선택했을 경우 쿠키 생성 함수 호출 setCookie("op1","true", 1) } else { //체크 박스를 해제했을 경우 쿠키 소멸 함수 호출 clearCookie("op1") } return } //--> </script> →이 스크립트는 하루동안 창 열지 않기를 위한것.
링크는 href="Javascript:win_link('http://ecell.co.kr/kkw_works/gesi/event1/index.htm');" 이런식으로 걸어주고.
오늘하루 창 열지 않기 체크하고 닫기버튼.
<form name="form1" method="post" action=""> <input type="checkbox" name="closeEvent" onClick="controlCookie(this)"> <font color="#FFFFFF">오늘 하루 이 창을 열지 않기</font> </form></td> <td width="33%" valign="bottom"><form name="form2" method="post" action=""> <a href="#" onclick="self.close()"> <input type="submit" name="Submit" value="닫기"> </a> </form>
|
|