Frage

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 }}

Keine korrekte Lösung

Andere Tipps

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);
}
});
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top