2012-11-22 21 views
2

這個東西仍然是真正的新東西,所以我希望我對這個問題的描述是準確的。Cookie + Zurb Reveal

我剛剛插上Zurb顯示,並得到了其與

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

現在在頁面加載工作,我怎麼一個cookie功能,使得該只顯示一次,每個用戶每天?我不希望每次用戶導航到主頁時都會出現此彈出窗口。

任何幫助,將不勝感激!

回答

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(); 
    } 
});