Вопрос

I don't want to disable the mouse scroll. I want to disable the click on the mouse wheel to scroll by moving the mouse up or down.

I've managed to do it for Chrome, IE, Opera and Safari, but not for Firefox.

Here's what I've used:

$(document).mousedown(function(e) {
    if(e.button == 1){  //also tried with if(e.which == 2){
        e.preventDefault();
        return false;
    }
});

Live demo

Это было полезно?

Решение 2

I don't think you can completely control it in Firefox.

You can make it snap back to the top of the page for example, like this:

$(document).on('mouseup', function(e) {
    if (e.button == 1) {
        window.scroll(0, 0);
    }
});

If you keep track of the scrolling position you can make it jump back to there.

Другие советы

You can disable this functionality by going to "about:config" and changing "general.autoScroll" to "false" (double-click on the record).

here's a very awkward solution for firefox since there isn't a good way to handle it. To prevent middle click scroller to appear in Firefox, make sure that <body> size is always less than window size, plus additionally putting <body style="overflow:hidden;">

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top