可以禁用滚动条而不是隐藏? [英] Possible to disable scrollbar instead of hiding?
问题描述
我想知道是否可以禁用滚动条而不是隐藏在页面上?当我打开一个模式对话框时,我希望它留在页面上,我只是不希望用户能够滚动主页面。所以完美的功能是:
短页面 - 根本没有滚动条;
长页面 - 滚动条出现;
长页面模式对话框打开 - 滚动条仍然存在,但无法使用。 解决方案
那么当你有一个模式时,你可以玩
onscroll
窗口
小提琴: http://jsfiddle.net/maniator/DmmEv /
$ b 代码:
var scrollX = window .scrollX,scrollY = window.scrollY;
window.onscroll = function(e){
scroll(scrollX,scrollY)
}
实例:
点击后,滚动条将保持不变我
小提琴: http://jsfiddle.net / maniator / DmmEv / 6 /
I was wondering if it is possible to disable a scrollbar instead of hiding it on a page? I want it to stay on the page when I open a modal dialog, I just don't want the users to be able to scroll the main page. So the perfect functionality would be:
short page - no scrollbar at all;
long page - scrollbar appears;
long page modal dialog open - scrollbar still there, but cannot be used.
Well when you have a modal you can just play around with the onscroll
of window
Fiddle: http://jsfiddle.net/maniator/DmmEv/
Code:
var scrollX = window.scrollX, scrollY = window.scrollY;
window.onscroll = function(e){
scroll(scrollX,scrollY)
}
Real Example:
Scrollbars will stay in place after clicking on Click Me
Fiddle: http://jsfiddle.net/maniator/DmmEv/6/
这篇关于可以禁用滚动条而不是隐藏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!