Reputation: 1271
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.
Upvotes: 3
Views: 1804
Reputation: 146350
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/
Upvotes: 3
Reputation: 91696
Maybe try:
<body style="overflow: scroll;">
Hello
<body>
Upvotes: -1