1

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

Nitin Varpe
  • 10,130
  • 5
  • 35
  • 58
Alvaro
  • 39,293
  • 27
  • 153
  • 316

3 Answers3

2

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

Jon
  • 21
  • 2
  • can you please elaborate? – Enamul Hassan Dec 19 '15 at 01:48
  • manetsus - I'm not sure what your are asking. Do you understand the original request? Have you tried my solution? It seems straight forward. Here's my solution restated. You can disable this functionality in Firefox by entering "about:config" in the address bar then selecting "config" in the list. In the resulting configuration listing change "general.autoScroll" to "false" by double clicking on the record. – Jon Dec 20 '15 at 04:23
1

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.

Ex-iT
  • 1,460
  • 2
  • 12
  • 20
1

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;">

Jacky Cheng
  • 1,461
  • 1
  • 10
  • 20