开发者

close fancybox after delay

开发者 https://www.devze.com 2023-04-12 15:02 出处:网络
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.

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 a开发者_开发知识库ssign 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.


You could make use of Javascript's setTimeout functionality.

So something along the lines of:

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


create a function to close all fancybox afterload and set timeout for that function.

$(document).ready(function () {
closefancybox();
});

function closefancybox() {
    $.fancybox({
        afterLoad: function () {$.fancybox.close();}
    });
    setTimeout(function () { closefancybox(); }, <time_interval>);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号