How can I disable the scroll bars of a page?

50,700

Solution 1

$(window).scroll(function() {
    scroll(0,0);
});

If you want to use it you need to have jQuery imported.

Solution 2

The scrollbars are a CSS issue. You can add this to your page (or the inner part to a CSS file):

<style type="text/css">
html, body {
  overflow: hidden;
}
</style>

Solution 3

You can't disable that button (or any other method of scrolling the page); see this. However, you could scrollTo(0,0) anytime you detect scrolling. This might look ugly (page scrolls a bit, then jumps back up).

For disabling the scrollbars, you can try setting html, body { overflow: hidden }; I think some browsers may not honor this.

(Wouldn't it be better to just create a page that fits into the viewport, so that the scrollbars aren't shown?)

Solution 4

document.body.scroll = "no";
document.body.style.overflow = 'hidden';
document.height = window.innerHeight;

should disable the scrollbars in most browsers.

See: http://www.eggheadcafe.com/community/aspnet/3/10088543/how-to-disable-document-body-from-scrolling.aspx

Solution 5

I am making a mobile website, but I don't want it to be a whole bunch of webpages, so I am making it one page with scrolling disabled. I did this with

   <style>
   html, body {
   overflow: hidden;
   }
   </style>
Share:
50,700
faressoft
Author by

faressoft

Updated on July 09, 2022

Comments

  • faressoft
    faressoft almost 2 years

    how to disable the scroll bars of the page.

    and disable this button.

    alt text

  • Adam
    Adam over 13 years
    @faresoft you still see a scrollbar despite trying each of those?
  • palswim
    palswim over 13 years
    So, this is jQuery? You might want to add that as a tag.
  • Srinivas
    Srinivas almost 11 years
    why should we give it for both html and body? Giving it to only html is not not sufficient?
  • emecas
    emecas over 9 years
    Does your answer improve upon any existing answer? It's a specific use case?