Firefox currently defines DOMMouseScroll events and wheels. Chrome, Opera and IE (last, again!) Define the mouse wheel.
Here is how I did it:
if(window.onwheel !== undefined) { window.addEventListener('wheel', onMouseWheel) } else if(window.onmousewheel !== undefined) { window.addEventListener('mousewheel', onMouseWheel) } else {
Note that addEventListener support in older versions of IE requires a polyfill. Alternatively, you can use the old window .mousewheel = function () {} or any other method.
As you can see, the event listener is attached to the window object. You cannot attach it to elements in a cross browser. You can use the target object property to see where it was called and make a filter based on it.
PS: Another cross-browser consideration: in IE you should use the "wheelDelta" property (and invert its sign!) Inside the event object when it is processed in the callback function ("onMouseWheel"). Other browsers will populate "deltaY" (or "deltaX" for horizontal scrolling).
source share