Cookie显示视频一次

Cookie to show video once

本文关键字:一次 显示 视频 Cookie      更新时间:2023-09-26

我有这段代码。谁能帮我设置1天的饼干?我需要视频每天只显示一次。

   var rfm = {
    setup: function() {
        jQuery('.video-landing').css('display', 'block');
        jQuery('.logo img').fadeOut(0);
    }
    init: function() {
        if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) >= 1040) {
            rfm.setup();
            setTimeout(function() {
                rfm.fadeOutVideo();
                rfm.fadeOutBackground();
                setTimeout(function() {
                    rfm.resizeAndRepositionLogo();
                    setTimeout(function() {
                        rfm.fadeOutOverlay();
                        rfm.fadeInSiteLogo();
                    }, 1500)
                }, 0);
            }, 3000);
        }
    }
}
jQuery(document).ready(function() {
    rfm.init();
});

您可以使用jQuery插件jQuery -cookie来设置/读取和删除cookie。从例子中:

$.cookie('video-disabled', '1', { expires: 1 });

截止日期以天为单位。读取cookie:

$.cookie('video-displayed');

检查是否设置了cookie。如果cookie存在,则返回值为"1",否则返回值为"undefined"。

你可能会发现这个页面很有用- Mozilla - cookie,但是我相信使用jQuery的插件会更容易。