Post
<script>
$( document ).ready(function() {
cookiedata = document.cookie;
if ( cookiedata.indexOf("ncookie=done") < 0 ){
document.getElementById('popup').style.display = "block"; // 팝업창 아이디
} else {
document.getElementById('popup').style.display = "none"; // 팝업창 아이디
}
});
function setCookie( name, value, expiredays ) {
var todayDate = new Date();
todayDate.setDate( todayDate.getDate() + expiredays );
document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";"
}
function closeWin() {
document.getElementById('popup').style.display = "none"; // 팝업창 아이디
}
function todaycloseWin() {
setCookie( "ncookie", "done" , 7 ); // 저장될 쿠키명 , 쿠키 value값 , 기간( ex. 1은 하루, 7은 일주일)
document.getElementById('popup').style.display = "none"; // 팝업창 아이디
}
</script>
사용법
<div id="popup" style="position:absolute; left:50%; top:120px; margin-left:-500px; z-index:1000; display:none;">
<img src="openpopup.jpg" usemap="#pop" />
<a href="#" onclick="todaycloseWin();" alt="오늘 하루 열지 않기"></a>
<a href="#" onclick="closeWin();" alt="닫기"></a>
</div>
'javascript, jQuery' 카테고리의 다른 글
자바스크립트 국내지도 svg 오버효과 (0) | 2018.05.31 |
---|---|
자바스크립트 지역셀렉트 선택 (0) | 2018.05.14 |
iframe 접근방법 (0) | 2018.03.23 |
자바스크립트 즐겨찾기 (0) | 2018.03.21 |
레이어 팝업시 스크롤 터치스크롤 막기 (0) | 2018.03.21 |