2

この件についてはまだ本当に新しいので、問題の説明が正確であることを願っています。

Zurb Reveal をプラグインしたところ、ページの読み込み時に動作するようになりました

$(document).ready(function (){
    $('#myModal').reveal();
});

では、ユーザーごとに 1 日に 1 回だけ表示されるように Cookie を機能させるにはどうすればよいでしょうか。ユーザーがホームページに移動するたびにこのポップアップが発生するのは望ましくありません。

どんな助けでも大歓迎です!

4

1 に答える 1

5

開発環境をセットアップできない

すでに jQuery を使用しているため、jQuery Cookie プラグイン (https://github.com/carhartl/jquery-cookie) を入手できます。次に、次のようなコードを使用できます。

$(document).ready(function(){
    // if the cookie doesn't exist create it and show the modal
    if ( ! $.cookie('hereToday') ) {

        // create the cookie. Set it to expire in 1 day
        $.cookie('hereToday', true, { expires: 1 });

        //call the reveal modal
        $('#myModal').reveal();
    }
});
于 2012-11-29T21:11:45.780 に答える