How can I disable the scroll bars of a page?

2019-04-06 08:12发布

how to disable the scroll bars of the page.

and disable this button.

alt text

7条回答
▲ chillily
2楼-- · 2019-04-06 08:32
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

查看更多
Ridiculous、
3楼-- · 2019-04-06 08:34

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?)

查看更多
Viruses.
4楼-- · 2019-04-06 08:35

This works: * {overflow: hidden} One problem I have when figuring it out was that I have a CSS drop-down (well slide across) menu on the page and that doesn't show when I use this method. I am still trying to figure out how to get the drop-down to work with this enabled.

查看更多
乱世女痞
5楼-- · 2019-04-06 08:39

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>
查看更多
倾城 Initia
6楼-- · 2019-04-06 08:46
$(window).scroll(function() {
    scroll(0,0);
});
查看更多
神经病院院长
7楼-- · 2019-04-06 08:58

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>
查看更多
登录 后发表回答