Skip to content

Instantly share code, notes, and snippets.

@naserr
naserr / onmousewheel.md
Created October 30, 2012 20:43 — forked from alimd/onmousewheel.md
The onmousewheel event of JavaScript

onmousewheel event and Firefox's equivalent

var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" ; //FF doesn't recognize mousewheel as of FF3.x
 
if (document.attachEvent) //if IE (and Opera depending on user setting)
    document.attachEvent("on"+mousewheelevt, function(e){alert('Mouse wheel movement detected!')});
else if (document.addEventListener) //WC3 browsers
    document.addEventListener(mousewheelevt, function(e){alert('Mouse wheel movement detected!')}, false);
@naserr
naserr / onmousewheel.md
Created October 21, 2012 15:20 — forked from alimd/onmousewheel.md
The onmousewheel event of JavaScript

onmousewheel event and Firefox's equivalent

var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" ; //FF doesn't recognize mousewheel as of FF3.x
 
if (document.attachEvent) //if IE (and Opera depending on user setting)
    document.attachEvent("on"+mousewheelevt, function(e){alert('Mouse wheel movement detected!')});
else if (document.addEventListener) //WC3 browsers
    document.addEventListener(mousewheelevt, function(e){alert('Mouse wheel movement detected!')}, false);