Search code examples
jquerypopuptimed

JQuery timer pop up after 2 minutes on website


I have a pop up which is timed to appear after 2 minutes on my web page, however I need it so that it will do this after 2 minutes on my website even if the user goes to another page. At the moment, it refreshes on each page load.

How would I do this? I presume some sort of session? Thanks in advance.

setTimeout(function(){ 
   $.fancybox({
       overlayOpacity: 0.8,
       overlayColor: '#000',
       type: 'iframe',
       width: 625,
       height: 550,
       overflow: 'auto',
       padding: 0,
       href: '<?php echo base_url(); ?>feedback'
   });
}, 1000*60*2);

Solution

  • I think the easy way is to set a cookie with a timestamp and keep track of the time in that way. I found this jQuery cookie plugin that maybe help you: http://archive.plugins.jquery.com/project/Cookie