Jump to content

Disable scrolling?


ShadowMage
 Share

Recommended Posts

Is it possible to somehow disable scrolling but keep the scrollbar?The reason I ask is that the way I'm doing it now (setting overflow: hidden; on the body) produces an odd little jitter in the page when the scrollbar disappears.

Link to comment
Share on other sites

Would it work to set overflow to scroll, and set both the html and body elements to 100% height? Be careful, though or IE could end up with 2 sets of scrollbars.(I haven't done this lately, but some combination in there does it, I think.)

Link to comment
Share on other sites

Would it work to set overflow to scroll, and set both the html and body elements to 100% height? Be careful, though or IE could end up with 2 sets of scrollbars.(I haven't done this lately, but some combination in there does it, I think.)
Well, it didn't create 2 scrollbars. :) Unfortunately, it also did not disable scrolling... :) I'll play around with some different combinations to see if I can get something to work.
Link to comment
Share on other sites

This is the magic combination:document.body.style.overflow = "hidden";document.documentElement.style.overflow = "scroll";document.body.style.height = "100%";document.documentElement.style.height = "100%";If you have padding on the body (which I do) you'll also have to use box-sizing: border-box; on the body element.Thanks for pointing me in the right direction, DD! :)

Edited by ShadowMage
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...