火狐浏览器中鼠标滚轮触发的事件如何实现?

更新于
2026-09-29 09:37:18
2阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计253个文字,预计阅读时间需要2分钟。

火狐浏览器中鼠标滚轮触发的事件如何实现?

鼠标滚轮事件在火狐下的兼容性问题

1. [代码] JavaScript代码// 兼容火狐的鼠标滚轮事件document.getElementById('t1').addEventListener('DOMMouseScroll', function(e) { scrollFunc(e, $('#table_1')), $('#table_1')});

鼠标滚轮事件在火狐下的兼容问题

1.[代码][JavaScript]代码

//兼容火狐的鼠标滚轮事件 document.getElementById("t1").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_1"),$("#pageNum"),$("#total")); },false); document.getElementById("t2").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_2"),$("#pageNum_phone"),$("#total_phone")); },false); document.getElementById("t3").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_3"),$("#pageNum_bus"),$("#total_bus")); },false); //chroom和ie下的鼠标滚轮事件 $('.table_1 table').on("mousewheel", function() { scrollFunc(e,$(this),$("#pageNum"),$("#total")); }); $('.table_2 table').on("mousewheel",function(){ scrollFunc(e,$(this),$("#pageNum_phone"),$("#total_phone")); }) $('.table_3 table').on("mousewheel",function(){ scrollFunc(e,$(this),$("#pageNum_bus"),$("#total_bus")); }) } function scrollFunc(e,that,pageNum,totalPage){ var e = e || window.event; if (e.wheelDelta) { if (e.wheelDelta > 0) { up(that,pageNum,totalPage);//chroom和ie下,鼠标滚轮向上滚 } if (e.wheelDelta < 0) { down(that,pageNum,totalPage);//chroom和ie下,鼠标滚轮向下滚 } } else if (e.detail) { if (e.detail> 0) { down(that,pageNum,totalPage);//火狐下,鼠标滚轮向下滚(与chroom和ie方向相反) } if (e.detail< 0) { up(that,pageNum,totalPage);//火狐,鼠标滚轮向上滚(与chroom和ie方向相反) } } }

火狐浏览器中鼠标滚轮触发的事件如何实现?

本文共计253个文字,预计阅读时间需要2分钟。

火狐浏览器中鼠标滚轮触发的事件如何实现?

鼠标滚轮事件在火狐下的兼容性问题

1. [代码] JavaScript代码// 兼容火狐的鼠标滚轮事件document.getElementById('t1').addEventListener('DOMMouseScroll', function(e) { scrollFunc(e, $('#table_1')), $('#table_1')});

鼠标滚轮事件在火狐下的兼容问题

1.[代码][JavaScript]代码

//兼容火狐的鼠标滚轮事件 document.getElementById("t1").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_1"),$("#pageNum"),$("#total")); },false); document.getElementById("t2").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_2"),$("#pageNum_phone"),$("#total_phone")); },false); document.getElementById("t3").addEventListener("DOMMouseScroll",function(e){ scrollFunc(e,$(".table_3"),$("#pageNum_bus"),$("#total_bus")); },false); //chroom和ie下的鼠标滚轮事件 $('.table_1 table').on("mousewheel", function() { scrollFunc(e,$(this),$("#pageNum"),$("#total")); }); $('.table_2 table').on("mousewheel",function(){ scrollFunc(e,$(this),$("#pageNum_phone"),$("#total_phone")); }) $('.table_3 table').on("mousewheel",function(){ scrollFunc(e,$(this),$("#pageNum_bus"),$("#total_bus")); }) } function scrollFunc(e,that,pageNum,totalPage){ var e = e || window.event; if (e.wheelDelta) { if (e.wheelDelta > 0) { up(that,pageNum,totalPage);//chroom和ie下,鼠标滚轮向上滚 } if (e.wheelDelta < 0) { down(that,pageNum,totalPage);//chroom和ie下,鼠标滚轮向下滚 } } else if (e.detail) { if (e.detail> 0) { down(that,pageNum,totalPage);//火狐下,鼠标滚轮向下滚(与chroom和ie方向相反) } if (e.detail< 0) { up(that,pageNum,totalPage);//火狐,鼠标滚轮向上滚(与chroom和ie方向相反) } } }

火狐浏览器中鼠标滚轮触发的事件如何实现?