[JavaScript 소스]
// 쿠키 입력
function set_cookie(name, value, expirehours, domain)
{
var today = new Date();
today.setTime(today.getTime() + (60*60*1000*expirehours));
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + today.toGMTString() + ";";
if (domain) {
document.cookie += "domain=" + domain + ";";
}
}
// 쿠키 얻음
function get_cookie(name)
{
var find_sw = false;
var start, end;
var i = 0;
for (i=0; i<= document.cookie.length; i++)
{
start = i;
end = start + name.length;
if(document.cookie.substring(start, end) == name)
{
find_sw = true
break
}
}
if (find_sw == true)
{
start = end + 1;
end = document.cookie.indexOf(";", start);
if(end < start) end = document.cookie.length;
return unescape(document.cookie.substring(start, end));
}
return "";
}
function setLayerPopupOpen( name ) {
var cc_name = get_cookie( name );
if( !cc_name ) {
$('.' + name).removeClass('hide');
}
}
function setLayerPopupClose(name, expirehours) {
$('.' + name).addClass('hide');
if( expirehours > 0 ) set_cookie(name, 'done', expirehours, g5_cookie_domain);
}
$(function(){
setLayerPopupOpen('.popup_01');
$('.popup_01 .close .btclose').click(function(){
var chk = $(this).parent().children('.closetxt').find('input[type=checkbox]');
var expirehours = ( chk.prop('checked') ) ? chk.val() : 0 ;
setLayerPopupClose('popup_01',expirehours);
});
});
[HTML 소스]
<div id="banner_rfix" class="popup_01 hide">
<div class="close">
<span class="closetxt"><input type="checkbox" name="expireHourCheck" value="24" id="expireHourCheck">
<label for="expireHourCheck">오늘 하루동안 보지 않기</label></span>
<span class="btclose">[닫기]</span>
</div>
</div>