views:

39

answers:

4

Hello all

I want to disable the scroll in one of my pages. I dont 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?

NLV

+1  A: 

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.

Amadan
A: 

I wonder if overflow: hidden; will work by putting it on the html, body selector in CSS?

eboyjr
Just tested in Firefox 3.6.8 and it works by putting it on the body element.
eboyjr
A: 

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.

Aaron Digulla
+2  A: 

document.body.style.overflow = 'hidden';

Marcelo