Search code examples
jqueryfancyboxlightboxdelay

close fancybox after delay


A client has me updating his static site with a few videos. He wants them to "pop up" and play on the site. I love fancybox mostly because I suck at jquery and it makes adding lightboxes so simple. I immediately installed that and so far everything is 100% perfect.

But he wants the fancybox window to close automatically after the clip is played. Since there are only a few videos and they are really short, I was going to just assign the time for each one. I think the longest is 1 min 30 sec and 5 videos in all.

How could I implement that? The fancybox site says "Within an iframe use - parent.$.fancybox.close();", but I have no idea how to make that work off of a delay in jquery. Any input or ideas would be awesome.


Solution

  • You could make use of Javascript's setTimeout functionality.

    So something along the lines of:

    setTimeout('parent.$.fancybox.close();', <time_interval>);