1

我试图让一个弹出框仅每 24 小时加载一次,但我不知道如何让 JQuery Click 事件接受/创建 cookie。我是相对论的新手。任何帮助,将不胜感激!

<link rel="stylesheet" href="colorbox.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="./colorbox/jquery.colorbox.js"></script>
    <script>
        $(document).ready(function(){
            $(".ajax").colorbox();
        });
    </script>
    <script>
        $(document).ready(function() { $('.ajax').click(); });
        // Create a cookie
        $.cookie('the_cookie', 'the_value');

        // Create expiring cookie, 7 days from then:
        $.cookie('the_cookie', 'the_value', { expires: 1 });

        // Read a cookie
        $.cookie('the_cookie'); // => 'the_value'
        $.cookie('not_existing'); // => null

        // EDIT
        // Attaching to a button click (jQuery 1.7+) and set cookie
        $("#ajax").on("click", function () {
            $.cookie('the_cookie', 'the_value', { expires: 1 });
        });

        // Attaching to a button click (jQuery < 1.7) and set cookie
        $("#ajax").click(function () {
            $.cookie('the_cookie', 'the_value', { expires: 1 });
        });
    </script>
</head>
<body>
    <p><a class='ajax' href="./content/ajax.html" title="Vote IG Top 100!"></a></p>
</body>

这是网页:

http://iconik-gaming.com/popup/

感谢大家!

4

0 回答 0