Show Jquery Popup Only Once

前端 未结 3 2010
一向
一向 2020-12-20 08:47

I have a site where a user must login and once that is done they are directed to a new page and a pop up box appears. I have no problem displaying the popup box however if y

相关标签:
3条回答
  • 2020-12-20 09:30

    While this thread may be ancient, I wanted to give an answer that OP could have used. By using cookies, you can set the page to only show once. Since most browsers support cookies, this is more reliable than using the internal storage engine that current browsers possess.

    $(document).ready(function(){
    
        // test for cookie here
        if ($.cookie('test_status') != '1') {
            //show popup here
            window.open('YOUR POPUP URL HERE','windowtest','toolbar=0,status=0,width=500,height=500');
    
            // set cookie here if not previous set
            var date = new Date();
            var minutes = 30;
            date.setTime(date.getTime() + (minutes * 60 * 1000));
            $.cookie('test_status', '1', {expires: date});
       }
    
    });
    

    To test this, be sure to clear your cookies between every refresh.

    0 讨论(0)
  • 2020-12-20 09:44

    You can use this for one time popup.

    $(window).load(function(){
            $('.popUp').show();
            $('.close').click(function(){
                $('.popUp').slideUp();
            });
            setTimeout('$(".popUp").fadeOut()', 10000);
        });
    
    0 讨论(0)
  • 2020-12-20 09:48

    you can use localstorage to do that:

    if (localStorage.getItem("iswrpdivloaded") === null) {
      $('#back-wrapper').fadeIn(1000,function(){
       $('#popup-image-back').fadeIn(1000);
    });
    localStorage.setItem('iswrpdivloaded', 1);
    }
    
    0 讨论(0)
提交回复
热议问题