源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

javascript 兼容鼠标滚轮事件

  • 时间:2021-11-14 06:55 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:javascript 兼容鼠标滚轮事件
这个事件在标准下和IE下是有区别的。firefox是按标准实现的,事件名为"DOMMouseScroll ",IE下采用的则是"mousewheel "。 当然一行代码就解决了兼容问题
[u]复制代码[/u] 代码如下:
var mousewheel = document.all?"mousewheel":"DOMMouseScroll";
[b]事件属性,IE是event.wheelDelta,Firefox是event.detail 属性的方向值也不一样,IE向上滚 > 0,Firefox向下滚 > 0。 [/b]最新的jquery1.3.2仍然没有增加滚轮事件,但可以用jquery的bind去绑定任何事件,当然得加上上面那句。 不过jquery有个插件已经加上了该功能。见http://brandonaaron.net/code/mousewheel/demos 这样使用:
[u]复制代码[/u] 代码如下:
$('div.mousewheel_example').mousewheel(fn); $('div.mousewheel_example').bind('mousewheel', fn);
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部