//滚动动画
windowAddMouseWheel();
function windowAddMouseWheel() {
var scrollFunc = function (e) {
e = e || window.event;
if (e.wheelDelta) { //判断浏览器IE,谷歌滑轮事件
if (e.wheelDelta > 0) { //当滑轮向上滚动时
$("#my_top").slideDown("slow");
$("#sl_last").slideUp("slow");
}
if (e.wheelDelta < 0) { //当滑轮向下滚动时
$("#my_top").slideUp("slow");
$("#sl_last").slideDown("slow");
}
} else if (e.detail) { //Firefox滑轮事件
if (e.detail> 0) { //当滑轮向上滚动时
$("#my_top").slideDown("slow");
$("#sl_last").slideUp("slow");
}
if (e.detail< 0) { //当滑轮向下滚动时
$("#my_top").slideUp("slow");
$("#sl_last").slideDown("slow");
}
}
};
//给页面绑定滑轮滚动事件
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', scrollFunc, false);
}
//滚动滑轮触发scrollFunc方法
window.onmousewheel = document.onmousewheel = scrollFunc;
}

参考大神写的,写博的时候网页关了,没找到原文地址,抱歉

js监控鼠标滚动事件的更多相关文章

  1. JS实现鼠标滚动事件,兼容IE9,FF,Chrome.

    <!-- 废话不多说,直接贴代码 --><script type="text/javascript" src="jquery.min.js"& ...

  2. JS鼠标滚动事件

    -----------------------------//鼠标滚动事件以下是JS临听鼠标滚动事件 并且还考虑到了各浏览器的兼容----------------------------------- ...

  3. js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写

    js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写 一.总结 一句话总结:滚动事件scroll(),浏览器窗口调整监听resize(),思考好监听对象. 1.滚动事件scroll()的监听对象是 ...

  4. js中鼠标滚轮事件详解

    js中鼠标滚轮事件详解   (以下内容部分内容参考了http://adomas.org/javascript-mouse-wheel/ ) 之前js 仿Photoshop鼠标滚轮控制输入框取值中已使用 ...

  5. js网页滚动条滚动事件实例分析

    本文实例讲述了js网页滚动条滚动事件用法.分享给大家供大家参考.具体分析如下: 在做js返回顶部的效果时,要监听网页滚动条滚动事件,这个事件就是:window.onscroll.当onscroll事件 ...

  6. 在FireFox浏览器上,用stopImmediatePropagation阻止冒泡鼠标滚动事件

    楔子 是不是在火狐用stopPropagation不太满意 很久没有笑过又不知为何 既然不快乐又不喜欢这里 不如一路向西用stopImmediatePropagation(其实我对浏览器的兼容性看不顺 ...

  7. vue组件添加鼠标滚动事件

    在一个组件标签上加鼠标滚动事件,应该写成    @mousewheel.native

  8. 鼠标滚动事件 - onmousewheel

    1.Jquery-MouseWheel jquery默认是不支持支持鼠标滚轮事件(mousewheel) jquery MouseWheel下载:https://github.com/jquery/j ...

  9. JavaScript一个鼠标滚动事件的实例

    <script type="text/javascript" src="./whenReady.js"></script> <!- ...

随机推荐

  1. python:递归函数(汉诺塔)

    #hanoi.py def hanoi(n,x,y,z): if n==1: print(x,"-->",z) else: hanoi(n-1,x,z,y) print(x, ...

  2. 《DSP using MATLAB》Problem 7.11

    代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...

  3. 统一社会信用代码+组织机构代码 校验 python

    转自: https://blog.csdn.net/warrah/article/details/69338912 https://blog.csdn.net/qq_37142340/article/ ...

  4. kafka-producer partitioner.class的使用

    partitioner.class的说明   在API客户端中封装好的partition( )方法会为消息选择一个分区编号.为了保证消息负载均衡到每个分区,可以通过使用默认方式或者 手动配置这个参数的 ...

  5. expect脚本实现ssh自动登录

    1:简单的实现ssh登录 #!/usr/bin/expect set ip "10.0.0.142" set user "root" set password ...

  6. 用jquery得到select选中的值

    <select class="pushtype" name="push_type" onchange="pushType(this)" ...

  7. LOJ 3057 「HNOI2019」校园旅行——BFS+图等价转化

    题目:https://loj.ac/problem/3057 想令 b[ i ][ j ] 表示两点是否可行,从可行的点对扩展.但不知道顺序,所以写了卡时间做数次 m2 迭代的算法,就是每次遍历所有不 ...

  8. C# 数据库

    连接: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...

  9. 位置式PID与增量式PID

    //位置式PID float Kp; float Ki; float Kd; float eSum,e0,e1; float pid_control(float now,float target) { ...

  10. 学习 Hadoop3.0 一、Hadoop3.0的安装与配置

    一.JDK1.8的安装 添加ppa sudo add-apt-repository ppa:webupd8team/java sudo apt-get update 安装Oracle-java-ins ...