5

Is there a way to disable scrolling? Not just the scrollbar, but the entire functionality from the browser window?

scriptgeeky
  • 165
  • 1
  • 2
  • 8
  • See this, it may help http://stackoverflow.com/questions/4770025/how-to-disable-scrolling-temporarily – Ana May 24 '12 at 20:21

3 Answers3

24

based on your answer to Keit you dont want to scroll be active when you have a lightbox open? 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

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');
Dejan.S
  • 16,281
  • 21
  • 64
  • 104
  • I'm surprised this does not have an outrageous number of votes on it. Very efficient. Thank you. – samurai_jane Aug 11 '16 at 11:19
  • Not sure why, but it doesn't work for me. This works: https://stackoverflow.com/questions/6411282/how-to-lock-scrolling-of-a-web-page-temporarily/6411611#6411611 – Hillcow Jul 11 '18 at 13:36
9

CSS

body
{
overflow: hidden;
}

javascript

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

jQuery

$("body").css('overflow', 'hidden');
Keith
  • 1,364
  • 1
  • 8
  • 18
  • 1
    That hides the scrollbar and generally "disables" the scroll function. However, in GWT have a popup window with some anchors and a div. When the anchor is clicked, it not only scrolls within the div, but also scrolls the page in the background. – scriptgeeky May 24 '12 at 20:13
3

If your GWT application is alone in your web page, you can use:

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

Window.enableScrolling(false);

for example in your onModuleLoad function.

Philippe Gonday
  • 1,689
  • 4
  • 20
  • 31