본문 바로가기
기타2/Jquery

오늘하루만 이창을 열지 않기[오늘로 설정]

by 죠부니 2017. 11. 3.
반응형

jquery.cookie.min.js사용

https://github.com/carhartl/jquery-cookie



오늘저녁시간을 알수있는 함수.

var currentDate = new Date();

expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);


작성 테스트시 console.log로 찍어본 값

currentDate : Fri Nov 03 2017 11:04:25 GMT+0900 (대한민국 표준시)

expirationDate : Sat Nov 04 2017 00:00:00 GMT+0900 (대한민국 표준시)



실제 팝업창에서 사용한 예제

if(confirm('하루동안 이창을 열지 않겠습니까?')) {

var currentDate = new Date();

expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);

$.cookie(아이디값, 'close', {

expires : expirationDate,

path : '/'

});

}



----

2018-01-23

단일팝업 추가부분

//팝업

//팝업 init

//쿠키 체크후 보임여부


if($.cookie("link_popup1") != "close"){

$("#link_popup1").css("display","block");

}

if($.cookie("link_popup2") != "close"){

$("#link_popup2").css("display","block");

}


//상단 팝업

$(".link_popup1_day_close").click(function(){

if(confirm('하루동안 이창을 열지 않겠습니까?')) {

var currentDate = new Date();

expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);

$.cookie("link_popup1", 'close', {

expires : expirationDate,

path : '/'

});

$("#link_popup1").css("display","none");

}


})


$(".link_popup1_close").click(function(){

$("#link_popup1").css("display","none");

})


//하단팝업

$(".link_popup2_day_close").click(function(){

if(confirm('하루동안 이창을 열지 않겠습니까?')) {

var currentDate = new Date();

expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);

$.cookie("link_popup2", 'close', {

expires : expirationDate,

path : '/'

});

$("#link_popup2").css("display","none");

}

})


$(".link_popup2_close").click(function(){

$("#link_popup2").css("display","none");

})


반응형

'기타2 > Jquery' 카테고리의 다른 글

브라우저마다 시간 타임존  (0) 2018.03.08
fancybox를 이용한 유튜브 팝업  (0) 2018.01.23
자주쓰는 MIME TYPE  (0) 2017.11.14
JQEURY SCROLL 이동  (0) 2017.10.11
jQuery.curCSS  (0) 2017.09.22