I want to disable the scroll in one of my pages. I don't want to write
scroll(0,0)
or scrollTo(0,0)
in the scroll event which will give a 'jumpy' nature. Can't I have something like
event.preventDefault()
for canceling the event?
I want to disable the scroll in one of my pages. I don't want to write
scroll(0,0)
or scrollTo(0,0)
in the scroll event which will give a 'jumpy' nature. Can't I have something like
event.preventDefault()
for canceling the event?
document.body.style.overflow = 'hidden';
The only acceptable way of preventing scrolling is making the content fit inside the window. Anything else, and you're pissing users off.
You can also use position: fixed
CSS - but still, if it's larger than the window, the rest is unusable, so you might as well follow the suggestion #1.
I wonder if overflow: hidden;
will work by putting it on the html, body
selector in CSS?
Create a div
that fills the whole area and set that to overflow: hidden
. That way, you will never get scroll bars and no scroll events will be created.