簡體   English   中英

設置具有cookie的彈出窗口的到期日期(和時間)

[英]Set an expiration date (and time) for a pop up that has a cookie

我可以添加以下哪些內容,以防止除夕夜晚上8點后加載彈出式窗口?

$(document).ready(function(){
    // Start Cookie for PopUp
    if (document.cookie.indexOf('colorframe=true') === -1) {
    var expires = new Date();
    expires.setDate(expires.getDate()+1);
    document.cookie = "colorframe=true; escKey=true; expires="+expires.toUTCString();

        // Start Popup
        setTimeout(function () {
            $.colorbox({
                escKey: true,
                html: '<a href="---"><img src="---" width="550" height="550" alt="New Years Eve at ---"/></a>'
            });
        }, 2000);
    };
});

您可以將當前時間戳與晚上8點的時間戳進行比較。 使用http://www.epochconverter.com/,我相信這是1483232400000。

$(document).ready(function(){
    // Start Cookie for PopUp
    if ((new Date).getTime() > 1483232400000) return;

    //remainder of code here

});

這是假設您信任客戶的計算機時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM