To implement the mouse scrolling wheel event:
<script type= "Text/javascript" ><pre name= "code" class= "JavaScript" > var scrollfunc=function (e) { e=e || window.event; if (E.wheeldelta) {//ie/opera/chrome if (e.wheeldelta==120) {//Scroll up Event alert (E.wheeldeta + "Up");} else{//Scroll Up Event alert (E.wheeldeta + "Up");} } else if (e.detail) { //firefox if (e.detail==-3) { //scroll up Event <br> alert (e.detail + "Up"); } else {//Scroll down Events <br> alert (e.detail + "Down");}} ; if (Document.addeventlistener) {//adding The event Listerner for Mozilla document.addeventlistener ("Dommousescroll", Scrollfunc, false); }//ie/opera/chrome Window.onmousewheel=document.onmousewheel=scrollfunc; </script>
There is one more way:
Using the Jquery.mousewheel.js plug-in, personally think this is very useful, similar to jquery encapsulated, to conquer the compatibility of a browser:
Use for example the following:
1. First import the Jquery.mousewheel.js file
2. Add the MouseWheel event to the area you want to use
<pre name= "Code" class= "JavaScript" ><pre name= "code" class= "JavaScript" > $ (function () { $ ("# XXXX "). Bind (" MouseWheel ", function (event) { event.preventdefault (); if (event.deltay== "-1") {//Scroll down event <br> }else{//scroll Up Event }} );
JavaScript scroll bar in response to mouse pulley implementation up and down scrolling events