하은양 믿음군 효실맘 호홍홍집s

날짜비교하여 팝업열기 샘플 본문

가벼운 배움/javascript

날짜비교하여 팝업열기 샘플

호홍홍집 2017. 1. 19. 17:38

<script language="javascript">

// 이부분부터  수정할 필요 없습니다.

function getCookie( name ) {

var nameOfCookie = name + '=';

var x = 0;

while ( x <= document.cookie.length ) {

var y = (x + nameOfCookie.length);

if ( document.cookie.substring( x, y ) == nameOfCookie ) {

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 '';

}


// 오늘날짜 체크 변수...

var v_ChkToday = new Date();

var v_ChkTodayYYYY = v_ChkToday.getFullYear();

var v_ChkTodayMM = v_ChkToday.getMonth();

if(parseInt(v_ChkTodayMM,10) < 9){

v_ChkTodayMM = parseInt(v_ChkTodayMM,10) + 1;

v_ChkTodayMM = '0'+v_ChkTodayMM;

}else{

v_ChkTodayMM = parseInt(v_ChkTodayMM,10) + 1;

}

var v_ChkTodayDD = v_ChkToday.getDate();

if(parseInt(v_ChkTodayDD,10) < 10){

v_ChkTodayDD = '0'+v_ChkTodayDD;

}

var v_ChkTodayHH = v_ChkToday.getHours();
if(parseInt(v_ChkTodayHH,10) < 10){
    v_ChkTodayHH = '0'+v_ChkTodayHH;
}

var v_ChkTodaymm = v_ChkToday.getMinutes();
if(parseInt(v_ChkTodaymm,10) < 10){
    v_ChkTodaymm = '0'+v_ChkTodaymm;
}

var v_strChkToday = v_ChkTodayYYYY +''+ v_ChkTodayMM +''+ v_ChkTodayDD +''+ v_ChkTodayHH +''+ v_ChkTodaymm;

var v_IntChkToday = parseInt(v_strChkToday,10);


// 팝업 처리 부분..

if(getCookie("popup1") != "done" && v_IntChkToday <= 201612301800){  // 2016.12.30 18:00이전까지 열림

// Window Popup

window.open('/popup/20160725.html','20160725','left=10,top=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=350, height=280');

// Layer Popup

document.getElementById('popup1').style.display = "block";

$("#popup1").draggable();

}


if(getCookie("popup1") != "done" && v_IntChkToday <= 201612300000){  // 2016.12.30 00:00이전까지 열림

// Window Popup

window.open('/popup/20160725.html','20160725','left=10,top=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=350, height=280');

// Layer Popup

document.getElementById('popup1').style.display = "block";

$("#popup1").draggable();

}


if(getCookie("popup1") != "done" && v_IntChkToday >= 201612300900 && v_IntChkToday <= 201701011800){  // 2016.12.30 09:00부터 2017.01.01 18:00 까지 열림

// Window Popup

window.open('/popup/20160725.html','20160725','left=10,top=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=350, height=280');

// Layer Popup

document.getElementById('popup1').style.display = "block";

$("#popup1").draggable();

}

</script>