问题
When fancybox fires the popup I want to have the close button disabled and just enable it after x seconds.
Is there any solution?
Thanks in Advance.
回答1:
This one is fun.
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
NOTE : this is for fancybox v2.1.3+
回答2:
for all users of fancybox the current latest version hide/show close icon with showCloseButton
doesn't work any more. After looking into the fancybox code i figured out closeBtn should be set to false. Use 'closeBtn' : false
to hide CloseIcon. Thanks
来源:https://stackoverflow.com/questions/13928018/delay-in-enable-and-disable-fancybox-close-button