1

So i want to disable the window scrolling on mousedown+mousemove, i searched everywhere, but i can't find anything.

body { overflow: hidden } doesn't work, you can still scroll if you press the mouse, and you go down.

The problem i have, is that on clicking on an image thumb, it opens a positioned absolute div (100% height & width and a 50% black transparent .png) that shows the original image, and when i press the left mouse button and i move down, all the items behind the absolute div, start to scroll down.

Here is an example of what is happening. http://jsfiddle.net/T2qBw/1/ (Click the black div, a position fixed div opens, press left click, and move down).

Thanks in advance.

PS: I apologize if i made any grammar or spelling mistake. (English isn't my native language)

Marcos Casagrande
  • 37,983
  • 8
  • 84
  • 98
  • possible duplicate of http://stackoverflow.com/questions/3656592/programmatically-disable-scrolling – K2xL Apr 15 '12 at 15:20

1 Answers1

3
$(".open-overlay").click(function(){
    $(".overlay").css("display","block");             
    $("body").css({overflow:'hidden'});  
    $(window).on('mousedown', function(e) {
        e.preventDefault();            
    })                    
});

Don't forget unbind mouse event $(window).off('mousedown')

Vitalii Petrychuk
  • 14,035
  • 8
  • 51
  • 55