2012-03-15 2 views
0

내 웹 사이트에서 자바 스크립트 팝업을 실행하면 사용자가 홈페이지를 클릭하면 자바 스크립트 팝업이 표시되지만 자바 스크립트 팝업이 표시됩니다. 사용자가 홈페이지를 다시 클릭하면 자바 스크립트가 실행되지 않으며이 스크립트는 하루 동안 만 활성화됩니다.자바 스크립트에서 쿠키 설정 - 팝업과 통합

그래서 내 자바 스크립트 팝업과 쿠키를 통합하는 방법은 무엇입니까?

* 이 팝업 실행 완벽하게 만 남아 쿠키 스크립트 이것이

URL http://tsubamecorp.com/home/index.php?route=extras/blog/getblogcategory&blogpath=41

내 자바 스크립트 팝업이 같은

<script> 

    var $xx = jQuery.noConflict(); 

    $xx(document).ready(function() { 

    //select all the a tag with name equal to modal 
    $xx('a[name=modal]').click(function(e) { 
     //Cancel the link behavior 
     e.preventDefault(); 

     //Get the A tag 
     var id = $xx(this).attr('href'); 

     //Get the screen height and width 
     var maskHeight = $xx(document).height(); 
     var maskWidth = $xx(window).width(); 

     //Set heigth and width to mask to fill up the whole screen 
     $xx('#mask').css({'width':maskWidth,'height':maskHeight}); 

     //transition effect  
     $xx('#mask').fadeIn(1000); 
     $xx('#mask').fadeTo("slow",0.90); 

     //Get the window height and width 
     var winH = $xx(window).height(); 
     var winW = $xx(window).width(); 

     //Set the popup window to center 
     $xx(id).css('top', winH/2-$xx(id).height()/1); 
     $xx(id).css('left', winW/2-$xx(id).width()/2); 

     //transition effect 
     $xx(id).fadeIn(1000); 

    }); 

    //if close button is clicked 
    $xx('.window .close').click(function (e) { 
     //Cancel the link behavior 
     e.preventDefault(); 

     $xx('#mask').hide(); 
     $xx('.window').hide(); 
    });    

}); 
</script> 
<script type="text/javascript"> 
window.onload = function() { $xx('a[href="#dialog1"]:eq(0)').click(); 
} 
</script> 
+0

매우 확실하지 않음 일부 document.cookie를 구글 ". 하루 활성이 스크립트를"다른 날이 오면 어느 날 내에서, 각 사용자가 한 번 팝업 창을 볼 수 있다는 것을 의미 않았다 다시 한 번 볼 수 있을까요? –

+0

당신이 말한 쿠키는 어디에 있습니까? 좀 더 명확하게 문제를 설명해주십시오. 제목이 약간 잘못되었습니다. 한 번의 클릭으로 팝업을 비활성화 하시겠습니까? – specialscope

+0

예 .. 24 시간에만 – ruslyrossi

답변

0

뭔가. 쿠키가 만료되면 sys에 의해 쿠키가 삭제 된 후에 만료됩니다. 귀하의 질문에 대한

Cookie = { 
    get:function (key) { 
     var ret = this.toObj()[key]; 
     if(ret === undefined){ 
      return ret; 
     } 
     return unescape (this.toObj()[key]); 
    }, 
    set:function (key, value, expires) { 
     if (expires){ 
      var exdata = new Date(); 
      exdata = exdata.setDate (exdata.setDate() + expires).toGMTString(); 
     } 
     document.cookie = key+"="+escape(value) + (exdata ? "; expires= " + exdata : ""); 
    }, 
    remove:function (key) { 
     document.cookie = key+"=remove;expires="+(new Date).toGMTString(); 
    }, 
    toJSON:function () { 
     return JSON.stringify(this.toObj); 
    }, 
    toObj:function () { 
     var ret={}, cookiearr = document.cookie.split(";"); 
     var i, start, key, value; 
     for (i = 0; l = cookiearr[ i++ ];) { 
      start = l.indexOf ("="); 
      ret [ l.slice(0, start) ] = l.slice (start+1); 
     } 
     return ret; 
    } 
} 
+0

ok..thanks .. 나는 시도 할 것이다. – ruslyrossi

관련 문제