Search code examples
javascriptjqueryiframecolorbox

How to delay opening of Colorbox iframe popup?


How would I add a delay (e.g 2 seconds) to my colorbox popup of an iframe

Here's my js, which is cookie-based

if (document.cookie.indexOf('colorframe=true') === -1) {
var expires = new Date();
expires.setDate(expires.getDate()+1);
document.cookie = "colorframe=true; escKey=true; expires="+expires.toUTCString();

(function($){
    $(document).ready(function() {
       $.colorbox({escKey:true,innerWidth:475,innerHeight:470,html:'<iframe width=475 height=470 src=http://www.mysite.com/popup-page frameborder=0 border=0 allowfullscreen></iframe>'});
    });
  }(jQuery)
)};

Thanks


Solution

  • try this

     setTimeout(function () {
         $.colorbox({
             escKey: true,
             innerWidth: 475,
             innerHeight: 470,
             html: '<iframe width=475 height=470 src=http://www.mysite.com/popup-page frameborder=0 border=0 allowfullscreen></iframe>'
         });
     }, 2000);