Firefox does not support the onmousewheel
name for this event. You'll need to do it with the DOMMouseScroll
event instead.
To detect whether onmousewheel
is supported, you can do something like this:
var cancelscroll = function(e) {
e.preventDefault();
};
if ("onmousewheel" in document) {
document.onmousewheel = cancelscroll;
} else {
document.addEventListener('DOMMouseScroll', cancelscroll, false);
}
Note that you needn't do this on DOM ready: the document will always be available to bind to, so you can do it immediately.
You ask how to remove the event listener in each case. A similar conditional will do the trick:
if ("onmousewheel" in document) {
document.onmousewheel = function() {};
} else {
document.removeEventListener('DOMMouseScroll', cancelscroll, false);
}