1.jsp
<div id="main_popup" class="main_popup" style="position: absolute; z-index:10000; top:0px; left:50%; display: none;">
<a href="" ><img src="" style="width:100%;height:400px;"/></a>
<div class="popup_bottom">
<a href="javascript:closePopupNotToday()" class="white">오늘하루 그만보기</a>
<a class="pull-right white" href="javascript:closePopup();">닫기</a>
</div>
</div>
2.javascript
사전준비
1. 쿠키 만들기
function setCookie(name, value, expiredays) {
var today = new Date();
today.setDate(today.getDate() + expiredays);
document.cookie = name + '=' + escape(value) + '; path=/; expires=' + today.toGMTString() + ';'
}
2. 쿠키 가져오기
function getCookie(name)
{
var cName = name + "=";
var x = 0;
while ( i <= document.cookie.length )
{
var y = (x+cName.length);
if ( document.cookie.substring( x, y ) == cName )
{
if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
endOfCookie = document.cookie.length;
return unescape( document.cookie.substring( y, endOfCookie ) );
}
x = document.cookie.indexOf( " ", x ) + 1;
if ( x == 0 )
break;
}
return "";
}
3. 오늘하루 그만보기
function closePopupNotToday(){
setCookie('notToday','Y', 1);
$("#main_popup").hide('fade');
}
그냥닫기
function closePopup(){
$("#main_popup").hide('fade');
}
4. 사용
$(window).ready(function(){
if(getCookie("notToday")!="Y"){
$("#main_popup").show('fade');
}
});
예제 :: http://trandent.com/jsTest/161538201593311