[js] 레이어팝업 오늘하루보지않기

devforest443·2022년 7월 27일
0

log 2015. 4. 30. 14:12

<div id="pop">    
  <div class="cont">        
    레이어 팝업 입니다.<br/>        
    <a href="#"><b>팝업창바로가기</b></a>    
  </div>    
  <div class="close">        
    <form method="post" action="" name="pop_form">             
      <span id="check">
        <input type="checkbox" value="checkbox" name="chkbox" id="chkday"/>
        <label for="chkday">오늘 하루동안 보지 않기</label>
      </span>            
      <span id="close">Close</span>        
    </form>    
  </div>
</div>
function getCookie(cname) {    
  var name = cname + "=";    
  var ca = document.cookie.split(';');    
  for(var i=0; i<ca.length; i++) {        
    var c = ca[i];        
    while (c.charAt(0)==' ') c = c.substring(1);        
    if (c.indexOf(name) != -1) return c.substring(name.length,c.length);    
  }    
  return "";
} 

function setCookie(cname, cvalue, exdays) {    
  var d = new Date();    
  d.setTime(d.getTime() + (exdays*24*60*60*1000));    
  var expires = "expires="+d.toUTCString();    
  document.cookie = cname + "=" + cvalue + "; " + expires;
} 

function couponClose(){    
  if($("input[name='chkbox']").is(":checked") ==true){        
    setCookie("close","Y",1);
  }    
  $("#pop").hide();
}

$(document).ready(function(){    
  cookiedata = document.cookie;
  if(cookiedata.indexOf("close=Y")<0) {        
    $("#pop").show();
  } else {        
    $("#pop").hide();
  }    
  $("#close").click(function(){        
    couponClose();                
  });
});
profile
devforest443

0개의 댓글