滚动条响应鼠标滑轮事件实现上下滚动的js代码
实现鼠标滚动滚轮事件:
<scripttype="text/javascript"> varscrollFunc=function(e){ e=e||window.event; if(e.wheelDelta){//IE/Opera/Chrome if(e.wheelDelta==120) { //向上滚动事件 alert(e.wheelDeta+"向上"); }else { //向上滚动事件 alert(e.wheelDeta+"向上"); } }elseif(e.detail){ //Firefox if(e.detail==-3){ //向上滚动事件<br> alert(e.detail+"向上"); }else{ //向下滚动事件<br> alert(e.detail+"向下"); } } }; if(document.addEventListener){ //addingtheeventlisternerforMozilla document.addEventListener("DOMMouseScroll",scrollFunc,false); } //IE/Opera/Chrome window.onmousewheel=document.onmousewheel=scrollFunc; </script>