jQuery 单击背景时禁用fancyBox 2关闭
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9732252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable fancyBox 2 from closing when clicking the background
提问by Mark Notton
In fancyBox 2, is there a key/value I could set that will disable the lightbox from closing when the user clicks the background (semi-transparent black background)?
在fancyBox 2 中,是否有我可以设置的键/值可以在用户单击背景(半透明黑色背景)时禁用灯箱关闭?
I only want to give them the option to click the actual (X) close button in the top right hand corner.
我只想让他们选择单击右上角的实际 (X) 关闭按钮。
Any ideas?
有任何想法吗?
Thanks.
谢谢。
回答by JFK
For version 2.x use
对于 2.x 版使用
$(".fancybox").fancybox({
closeClick : false, // prevents closing when clicking INSIDE fancybox
helpers : {
overlay : {closeClick: false} // prevents closing when clicking OUTSIDE fancybox
}
});
if closeClick
is set to true
(default) fancybox will close if clicking over the content so with these two combined options the only possible way to close fancybox is with the close
(X) button
如果closeClick
设置为true
(默认)fancybox 将在单击内容时关闭,因此使用这两个组合选项关闭fancybox 的唯一可能方法是使用close
(X) 按钮
回答by MrBizle
This will disable closing fancybox when clicking on the overlay (the semi-transparent background)
单击叠加层(半透明背景)时,这将禁用关闭花式框
fancyEls.fancybox({
helpers : {
overlay : {
closeClick: false
} // prevents closing when clicking OUTSIDE fancybox
}
});
This will disable all default click methods of closing fancybox
这将禁用关闭fancybox的所有默认点击方法
fancyEls.fancybox({
closeBtn : false,
closeClick : false,
helpers : {
overlay : {
closeClick: false
} // prevents closing when clicking OUTSIDE fancybox
},
keys : {
close: null
} // prevents close when clicking escape button
});
And this will do the same as well as disabling slideshow functionality
这将执行相同的操作以及禁用幻灯片功能
fancyEls.fancybox({
modal : true //If set to true, will disable navigation and closing
});
回答by Sreenath Plakkat
try this let adduserbe my target selector
试试这个让adduser成为我的目标选择器
$('.adduser').fancybox({
'hideOnOverlayClick': false
});
回答by David 'the bald ginger'
According to the Fancybox site APIyou could/should use
根据您可以/应该使用的Fancybox 站点 API
$.fancybox({
...
'hideOnOverlayClick' : false,
...
});
回答by shraboni
To prevent close button- use:
为防止关闭按钮 - 使用:
defaults: { closeBtn : false,}
To prevent overlay close - use :
为了防止覆盖关闭 - 使用:
F.helpers.overlay = {
defaults : {closeClick : false, // if true, fancyBox will be closed when user clicks on the overlay }}
To prevent escape click close :
为了防止逃逸点击关闭:
defaults: {keys : {//close : [27], // escape key
close : null, } }