문제

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)

도움이 되었습니까?

해결책

$(".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')

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top