문제

I've tried the various work arounds that have been mentioned in similar posts but I am still unable to make my modal window show only once per browsing session using the cookie. This is what my script looks like, if anyone can help me that would be perfect:

<script>  
$(document).ready(function() {
    if ($.cookie('modal_shown') == null) {
        $.cookie('modal_shown', 'yes', { expires: -1, path: '/' });
        setTimeout(function(){
          $("#modal").fadeIn(500);
        },7000);
    }
});
</script>
<script>
    $('#close').click(function() {
      $('#modal').hide();
    }
);
  </script>

And this is what my links look like:

<!--Modal-->
      <script type="text/javascript"  src="http://code.jquery.com/jquery-latest.min.js"></script>
      {{ "jquery-cookie.js" | asset_url | script_tag }}

올바른 솔루션이 없습니다

다른 팁

the expires option is not working. please try like this

$(document).ready(function () {
alert('I am ready');
if ($.cookie('modal_shown') == null) {
    $.cookie('modal_shown', 'yes');

    setTimeout(function(){
      $("#modal").fadeIn(500);
    },7000);
}
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top