Javascript 禁用浏览器滚动条

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4342686/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 11:59:20  来源:igfitidea点击:

Disabling browser scrollbar

javascriptjquery

提问by Nithesh Narayanan

Hi Is it possible to disable browser scroll bar through java script...? If yes how?

嗨是否可以通过java脚本禁用浏览器滚动条...?如果是如何?

Help me if anybody knows it... Thanks in advance..

如果有人知道,请帮助我...提前致谢...

回答by rahul

CSS

CSS

body
{
    overflow: hidden;
}

javascript

javascript

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

jQuery

jQuery

$("body").css('overflow', 'hidden');

回答by Chinmayee G

Use this CSS

使用这个 CSS

body {
   overflow:hidden;
}

回答by Anish Joseph

ya sure you can disable browser scroll bar just give overflow hidden for body tag using css and javascript

您确定您可以禁用浏览器滚动条,只需使用 css 和 javascript 为 body 标记隐藏溢出

or just put an id for the body tag and use

或者只是为 body 标签添加一个 id 并使用

eg HTML

例如 HTML

<body id="page">

JAVASCRIPT

爪哇脚本

 document.getElementById( "page" ).style.overflow= "hidden";

回答by Mudassir

Use the following snippet;

使用以下代码段;

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