时间:2021-07-01 10:21:17 帮助过:5人阅读
实现鼠标滚动滚轮事件:
<script type="text/javascript"> var scrollFunc=function(e){ e=e || window.event; if(e.wheelDelta){//IE/Opera/Chrome if(e.wheelDelta==120) { //向上滚动事件 alert(e.wheelDeta +"向上"); }else { //向上滚动事件 alert(e.wheelDeta +"向上"); } }else if(e.detail){ //Firefox if(e.detail==-3) { //向上滚动事件<br> alert(e.detail +"向上"); }else { //向下滚动事件<br> alert(e.detail +"向下 "); } } }; if(document.addEventListener){ //adding the event listerner for Mozilla document.addEventListener("DOMMouseScroll" ,scrollFunc, false); } //IE/Opera/Chrome window.onmousewheel=document.onmousewheel=scrollFunc; </script>