Skip to content

Instantly share code, notes, and snippets.

@JuniorMSG
Created May 3, 2021 00:25
Show Gist options
  • Save JuniorMSG/94aa4962eadea79fc6e69a632cfb8746 to your computer and use it in GitHub Desktop.
Save JuniorMSG/94aa4962eadea79fc6e69a632cfb8746 to your computer and use it in GitHub Desktop.
// 쿠키 설정
function setCookie(name, value, expiredays){
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";";
}
// 쿠키 확인
function getCookie(name) {
var nameOfCookie=name+"=";
var a=0;
while(a<=document.cookie.length) {
var b=(a+nameOfCookie.length);
if(document.cookie.substring(a,b)==nameOfCookie) {
if((endOfCookie=document.cookie.indexOf(";",b))==-1)
endOfCookie=document.cookie.length;
return unescape(document.cookie.substring(b,endOfCookie));
}
a=document.cookie.indexOf(" ",a) +1;
if(a==0)
break;
}
return "";
}
function notToday(){
setCookie("rward", 1, 1);
window.close();
}
// 오늘하루 열지않기 누르기
function ClosePopup( $cookieName ){
setCookie($cookieName, 'done', 1);
window.close();
}
// 팝업 열때 쿠키 확인 하고 없으면 팝업 열기
function Init( $class ){
if(getCookie($class) != 'done') {
window.open("url");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment