본문 바로가기
Web Programing!/Script

팝업창 오늘하루안띄우기

by 어설픈봉봉이 2011. 11. 26.
반응형
SMALL

  


<script>

   function notice_GetCookie(name)
  {
     var arg = name + "=";
     var alen = arg.length;
     var clen = document.cookie.length;
     var i = 0;
     while (i < clen) //while open
     {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    } //while close
    return null;
  }


function getCookieVal (offset)
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}


function fncOnload()
{

// 팝업창에서 하루동안 열지 않기시 등록된 Key 값인 'Notice' 로 등록된 값이 'done'  인지 체크한 후 값이 일치하지 않는 경우만 팝업창이 실행되도록 변경.

    if( notice_GetCookie('Notice') != 'done' )
    {
        window.open('팝업창경로','팝업이름','속성들');
    }
}

</script>



소스상의 body 함수가 로딩된 후 팝업을 처리하도록 onload 함수를 추가.

<body onload='javascript:fncOnload();'>



반응형