js监控鼠标滚动事件
//滚动动画
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监控鼠标滚动事件的更多相关文章
- JS实现鼠标滚动事件,兼容IE9,FF,Chrome.
<!-- 废话不多说,直接贴代码 --><script type="text/javascript" src="jquery.min.js"& ...
- JS鼠标滚动事件
-----------------------------//鼠标滚动事件以下是JS临听鼠标滚动事件 并且还考虑到了各浏览器的兼容----------------------------------- ...
- js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写
js进阶 12-6 监听鼠标滚动事件和窗口改变事件怎么写 一.总结 一句话总结:滚动事件scroll(),浏览器窗口调整监听resize(),思考好监听对象. 1.滚动事件scroll()的监听对象是 ...
- js中鼠标滚轮事件详解
js中鼠标滚轮事件详解 (以下内容部分内容参考了http://adomas.org/javascript-mouse-wheel/ ) 之前js 仿Photoshop鼠标滚轮控制输入框取值中已使用 ...
- js网页滚动条滚动事件实例分析
本文实例讲述了js网页滚动条滚动事件用法.分享给大家供大家参考.具体分析如下: 在做js返回顶部的效果时,要监听网页滚动条滚动事件,这个事件就是:window.onscroll.当onscroll事件 ...
- 在FireFox浏览器上,用stopImmediatePropagation阻止冒泡鼠标滚动事件
楔子 是不是在火狐用stopPropagation不太满意 很久没有笑过又不知为何 既然不快乐又不喜欢这里 不如一路向西用stopImmediatePropagation(其实我对浏览器的兼容性看不顺 ...
- vue组件添加鼠标滚动事件
在一个组件标签上加鼠标滚动事件,应该写成 @mousewheel.native
- 鼠标滚动事件 - onmousewheel
1.Jquery-MouseWheel jquery默认是不支持支持鼠标滚轮事件(mousewheel) jquery MouseWheel下载:https://github.com/jquery/j ...
- JavaScript一个鼠标滚动事件的实例
<script type="text/javascript" src="./whenReady.js"></script> <!- ...
随机推荐
- zombodb 索引管理
zombodb 支持标准的index 管理(create .alter.drop) 创建索引 CREATE INDEX index_name ON table_name USING zombodb ( ...
- ipc基础
ipc对象持久性 进程持久性:具有这种持久性的对象在持有它的最后一个进程关闭了该对象为止 内核持久性:这种IPC对象一直存在直到内核重新自举或显示删除该对象为止 文件系统持久性:具有这种持久性的对象只 ...
- Zookeeper 集群搭建--单机伪分布式集群
一. zk集群,主从节点,心跳机制(选举模式) 二.Zookeeper集群搭建注意点 1.配置数据文件 myid 1/2/3 对应 server.1/2/3 2.通过./zkCli.sh -serve ...
- 在mysql数据库中创建Oracle数据库中的scott用户表
在mysql数据库中创建Oracle数据库中的scott用户表 作者:Eric 微信:loveoracle11g create table DEPT ( DEPTNO int(2) not null, ...
- 时间的转化 js
php 和java是不一样的 PHP 需要先乘1000 java 不需要 因为PHP传过来的是十位数 java传过来是十三位数 function formatDate() { var now = n ...
- text-transform CSS
text-transform 控制文本的大小写(只对英文起作用,对汉字无效) Example: <p class="p1">This is an HI Element ...
- 204. jetcache:在Spring Boot中怎么玩?
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源 ...
- 202. 阿里Pandora Boot
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源 ...
- 195. Spring Boot 2.0数据库迁移:Flyway
[视频&交流平台] àSpringBoot视频:http://t.cn/R3QepWG à SpringCloud视频:http://t.cn/R3QeRZc à Spring Boot源码: ...
- Servlet 教程 各个知识点简单概括
Servlet 教程 http://www.ziqiangxuetang.com/servlet/servlet-cookies-handling.html Servlet 教程 Servlet 教程 ...