简体   繁体   English

禁用任何类型的浏览器窗口滚动?

[英]Disable browser window scrolling of any kind?

Is there a way to disable scrolling? 有没有办法禁用滚动? Not just the scrollbar, but the entire functionality from the browser window? 不仅仅是滚动条​​,还有浏览器窗口的整个功能?

based on your answer to Keit you dont want to scroll be active when you have a lightbox open? 根据你对Keit的回答,你不想在打开灯箱时滚动显示? if that is the case you can add a class to the body at the same time as you open the lightbox with the following css 如果是这种情况,您可以在使用以下css打开灯箱的同时向主体添加类

And the nice thing about this solution it keeps the scroll "space" so the site do not jump, its more like it disables it. 关于这个解决方案的好处是它保持滚动“空间”,所以网站不跳,它更像是禁用它。 hope this helps 希望这可以帮助

body.noscroll
{
    position: fixed; 
    overflow-y: scroll;
    width: 100%;
}



$('body').addClass('noscroll');
$('body').removeClass('noscroll');

CSS CSS

body
{
overflow: hidden;
}

javascript JavaScript的

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

jQuery jQuery的

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

If your GWT application is alone in your web page, you can use: 如果您的网页中单独使用GWT应用程序,则可以使用:

import com.google.gwt.user.client.Window;
// ...

Window.enableScrolling(false);

for example in your onModuleLoad function. 例如在你的onModuleLoad函数中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM