延迟启用和禁用fancybox关闭按钮 [英] Delay in Enable and disable fancybox close button

查看:105
本文介绍了延迟启用和禁用fancybox关闭按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当fancybox触发弹出窗口时,我想禁用关闭按钮,仅在x秒后启用它.

When fancybox fires the popup I want to have the close button disabled and just enable it after x seconds.

有什么解决办法吗?

预先感谢.

推荐答案

这很有趣.

如果要隐藏关闭按钮以至少在10秒钟内阻止关闭,则可能还想禁用在fancybox内部或外部单击的关闭....因此,请尝试在afterShow回调中使用setTimeout就像:

If you want to hide the close button to prevent the closing at least during 10 seconds, you may also want to disable closing on click either inside or outside fancybox .... so try setTimeout inside the afterShow callback like :

$(".fancybox").fancybox({
    closeClick: false, // prevents closing when clicking INSIDE fancybox 
    helpers: { overlay: { closeClick: false } }, // prevents closing when clicking OUTSIDE fancybox
    afterShow: function() {
        $(".fancybox-close").hide(); // hide close button
        setTimeout(function() {
            $(".fancybox-close").fadeIn();
        }, 10000); // show close button after 10 seconds
    }
});​

请参见 演示

See DEMO

注意:适用于fancybox v2.1.3 +

NOTE : this is for fancybox v2.1.3+

这篇关于延迟启用和禁用fancybox关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆