Fancybox popup once time for session

前端 未结 3 1020
臣服心动
臣服心动 2021-01-06 23:39

I have a popup with fancybox that appear at load page.

I need to show the popup once a time, if the user change page and back on the page with popup doesn\'t reveal

3条回答
  •  感情败类
    2021-01-07 00:13

    Using the jQuery cookie plugin you suggested:

    $(document).ready(function() {
        if(typeof $.cookie('popupVideoPlayed') == 'undefined') {
            $.cookie('popupVideoPlayed', 'true'); // set a session cookie so it won't play again
            $('#yt').trigger('click');
        }
    });
    

    Remember to delete the inline body onload event handler.

提交回复
热议问题