2012. 3. 29. 15:59 Web/javascript
- index
<script type="text/javascript">
//<![CDATA[
window.open("popup.html","pop","left=10,top=30, scrollbars=no, resizable=no , width=572, height=438, status=no, toolbar=no , location=no");
//]]>
</script>
</head>
- index(오늘하루 열지않기)
<!--팝업스크립트-->
<SCRIPT LANGUAGE="JavaScript">
function getCookie(name)
{
var Found ;
Found = false ;
var start, end ;
var i = 0 ;
// cookie 문자열 전체를 검색
while(i <= document.cookie.length){
start = i ;
end = start + name.length ;
// name과 동일한 문자가 있다면
if(document.cookie.substring(start, end) == name) {
//Found = true ;
return true;
break ;
}
i++ ;
}
// name 문자열을 cookie에서 찾았다면
if(Found == true)
{
start = end + 1 ;
end = document.cookie.indexOf(';', start) ;
// 마지막 부분이라는 것을 의미(마지막에는 ";"가 없다)
if(end < start)
end = document.cookie.length ;
// name에 해당하는 value값을 추출하여 리턴한다.
return document.cookie.substring(start, end) ;
}
// 찾지 못했다면
return '' ;
}
//팝업테스트
if (getCookie('popup') != true)
window.open('/'popup'.php, 'popup', 'left=0,top=0,toolbar=no,status=no,width=400 height=579,directories=no,scrollbars=no,location=no,resizable=no,menubar=no');
</SCRIPT>
- popup.php
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>팝업</title>
<link rel="stylesheet" href="css.css" type="text/css">
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--
function controlCookie(elemnt) {
if (elemnt.checked) {
//체크 박스를 선택했을 경우 쿠키 생성 함수 호출
setCookie("popup","true", 1);
}
else {
//체크 박스를 해제했을 경우 쿠키 소멸 함수 호출
clearCookie("popup")
}
return
}
//쿠키 생성 함수
function setCookie(name, value, expire) {
var expire_date = new Date()
expire_date = new Date(expire_date.getTime() + 60*60*24*1000)
document.cookie = name + "=" + escape(value) + "; expires=" + expire_date.toGMTString() +"; path=/";
self.close();
}
//쿠키 소멸 함수
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()
}
//-->
</SCRIPT>
<script language="javascript">
function go_event1()
{
opener.location.href="#";
window.close();
}
</script>
<body text="black" link="blue" vlink="purple" alink="red" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%">
<p><img src="/images/pop01.jpg" border="0" ></p>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#000000">
<tr>
<td height="20" class=td>
<p align="right"><input type="checkbox" name="checkbox" value="checkbox" onclick="controlCookie(this)"></p>
</td>
<td width="100%" height="20" class=td>
<p><font color="#ffffff" size="2px">오늘은 이 창을 다시열지 않음</font></p>
</td>
<td width="110" height="20" class=td>
<p> </p>
</td>
</tr>
</table>
<map name="Map1">
<area shape="rect" coords="41, 78, 356, 226" href="#" onclick="go_event1()" onfocus=this.blur()>
</map>
</BODY>
</HTML>
페이지 링크 (0) | 2012.04.12 |
---|---|
클릭시 팝업창 띄우기 (0) | 2012.04.12 |
버튼 클릭시 레이어 팝업 띄우기 (0) | 2012.03.23 |
서브네비 (2) | 2012.03.14 |
이미지맵으로 주소창 없는 새창 띄우기 (0) | 2012.03.14 |