[英]Disable scrolling of a window in jQuery
I am using something like facebox , and want the main window scrolling bar to be disabled. 我正在使用诸如facebox之类的东西 ,并希望禁用主窗口滚动条。 One catch though, There is a scroll bar inside the facebox component, which needs to be able to scroll.
不过有一个问题, facebox组件内部有一个滚动条,它需要能够滚动。
What I am trying to fix is the following case: 我要解决的是以下情况:
when scrolling the internal scrolling element (inside facebox ), when scroll ends, it scrolls the page down further. 当滚动内部滚动元素(在facebox内 )时,滚动结束时,它将进一步向下滚动页面。
do it in css: 在CSS中执行:
body {
overflow: hidden;
}
this would hide the scrollbar in the main window 这将在主窗口中隐藏滚动条
i went into the facebox.js file and added 我进入facebox.js文件并添加
$('body').css('overflow', 'hidden');
to 至
loading: function() {
init()
if ($('#facebox .loading').length == 1) return true
showOverlay()
$('#facebox .content').empty()
$('body').css('overflow', 'hidden');
$('#facebox .body').children().hide().end().
append('<div class="loading"><img src="'+$.facebox.settings.loadingImage+'"/></div>')
and added $('body').css('overflow', ''); 并添加$('body')。css('overflow',''); to the end of the document
到文件末尾
* Bindings
*/
$(document).bind('close.facebox', function() {
$(document).unbind('keydown.facebox')
$('#facebox').fadeOut(function() {
$('#facebox .content').removeClass().addClass('content')
$('#facebox .loading').remove()
$(document).trigger('afterClose.facebox')
$('body').css('overflow', '');
})
hideOverlay()
})
})(jQuery);
This stops the scroll when open and when closed put the scroll back in, it worked for me at http://www.vestedutility.com.au/home_electrical_saftey_check.php 这会在打开时停止滚动,而在关闭时将其重新放回去,它对我有用, 网址为http://www.vestedutility.com.au/home_electrical_saftey_check.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.