您好,欢迎访问一九零五行业门户网

JS实现判断鼠标是否滚动的代码

本文主要和大家分享js实现判断鼠标是否滚动,主要以代码的形式和大家分享,希望能帮助到大家。
<script> var scrollfunc = function (e) { var direct = 0; e = e || window.event; if (e.wheeldelta) { //判断浏览器ie,谷歌滑轮事件 if (e.wheeldelta > 0) { //当滑轮向上滚动时 alert("滑轮向上滚动"); } if (e.wheeldelta < 0) { //当滑轮向下滚动时 alert("滑轮向下滚动"); } } else if (e.detail) { //firefox滑轮事件 if (e.detail> 0) { //当滑轮向上滚动时 alert("滑轮向上滚动"); } if (e.detail< 0) { //当滑轮向下滚动时 alert("滑轮向下滚动"); } } scrolltext(direct); } //给页面绑定滑轮滚动事件 if (document.addeventlistener) { document.addeventlistener('dommousescroll', scrollfunc, false); } //滚动滑轮触发scrollfunc方法 window.onmousewheel = document.onmousewheel = scrollfunc; </script>
相关推荐:
详解js判断内容区域是否滚动到底部
以上就是js实现判断鼠标是否滚动的代码的详细内容。
其它类似信息

推荐信息