In my last scripting article, I showed you how to use native JavaScript to disable mouse wheel scrolling and re-enable it afterwards. Now that you know it (you read it right?), I will show you the simpler MooTools way.

MooTools (or any good framework) will provide a single method that should work across all browsers.

For instance, instead of having to deal with 2 forms of event registration for Internet Explorer vs. everything else, we now have a single method addEvent().

Solid Tip: Notice I am using document and not window in my methods below. window will not capture mouse wheel events in IE7 and IE8.

Disabling the Mouse Wheel

JAVASCRIPTview code
document.addEvent("mousewheel",function(e){ e.preventDefault(); });

Re-enabling

JAVASCRIPTview code
document.removeEvents("mousewheel");

That was easy! Standard JavaScript took about 13 lines of code total. MooTools lets us do it in 2. If you’re a MooTools user and would like to see techniques for any topic, leave a comment. Thanks!