출처 : http://blog.naver.com/roadpie/70160796618
위 블로그를 참고하여 기본 기능은 두고 쿠키 삭제 버튼만 추가하였습니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ko" xml:lang="ko">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
div.popup001 { background:#fff repeat left top;}
h1.popup { padding:15px 0 0 19px; height:64px; float:none; }
div.popup002 { padding:0px 0px; line-height:130%; }
p.popup-close {height:20px;border-top:1px #c6c6c6 solid; text-align:right;background:#ccc repeat left top;}
p.popup-close input, p.popup-close img { vertical-align:middle;}
p.popup-close label{padding:0 0 0 4px;}
p.popup-close a{color:#000;text-decoration:none;line-height:20px;padding:0 10px 0 0;}
</style>
<script language="JavaScript">
function setCookies1( name, value, expires ) {
document.cookie = name + "=" + escape (value) +
"; path=/; expires=" + expires.toGMTString();
}
function closeWin(objname,pop) {
var expdate = new Date();
expdate.setTime(expdate.getTime() + 24*60*60*1000 ); // *365 365일
setCookies1( pop, "done" , expdate );
document.getElementById(objname).style.display = "none";
}
function close(objname) {
document.getElementById(objname).style.display = "none";
}
function getCookies1(Name) {
var search = Name + "=";
offset = document.cookie.indexOf(search);
if (document.cookie.length > 0) { // 쿠키가 설정되어 있다면
if (offset != -1) { // 쿠키가 존재하면
offset += search.length;
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// 쿠키 값의 마지막 위치 인덱스 번호 설정
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(offset, end));
}
}
}
function win_link(url_link)
{
location.href=url_link;
}
function deleteCookies() {
var count = 0;
if (document.cookie != "") {
var cookies = document.cookie.split("; ");
count = cookies.length;
var expireDate = new Date();
expireDate.setDate(expireDate.getDate() -1);
for (var i=0; i<count; i++) {
var cookieName = cookies[i].split("=")[0];
document.cookie = cookieName + "=; path=/; expires=" + expireDate.toGMTString();
}
}
alert('Cookie delete Complete.');
}
</script>
</head>
<body>
<span style="cursor:pointer;" onclick="deleteCookies();"><font color=red>▷Delete Cookie◁</font> </span><br>
<form name="notice0">
<div class="popup001" id="popup0" style="Z-INDEX:9999;margin-left:80px; TOP:100px; width:394px;POSITION:absolute;display:none;height:279px; ">
<div class="popup002">
<img src="/images/img/pop_20130206.jpg" alt="" />
popup show
</div>
<p class="popup-close">
<input type="checkbox" id="chk1" name="chk" onclick="closeWin('popup0','popup0');" />
<a href="javascript:void(closeWin('popup0','popup0'));">today not show</a>
<a href="javascript:void(closeWin('popup0'));">close</a>
</p>
</div>
</form>
<script language="javascript" type="text/javascript">
if (getCookies1("popup0") != "done") {
document.getElementById('popup0').style.display = 'block';
}
//-->
</script>
</body>
</html>