Cookie + Zurb Reveal

时间:2012-11-22 03:41:24

标签: jquery cookies zurb-foundation

这个东西仍然是新的,所以我希望我对这个问题的描述是准确的。

我刚刚插入Zurb Reveal,并在

页面加载时工作
$(document).ready(function (){
    $('#myModal').reveal();
});

现在我如何让cookie运行,以便每个用户每天只显示一次?我不希望每次用户导航到主页时都会弹出此弹出窗口。

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分: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();
    }
});
相关问题