How to fire mouse wheel event in Firefox with JavaScript?

一世执手 提交于 2019-11-30 06:18:54

Well,

  1. In the Mozilla part of the code, if you're listening for DOMMouseScroll you should dispatch a DOMMouseScroll event too, no? (mousewheel seems to be a Microsoft invention copied by webkit, but not Gecko).
  2. Instead of setting (readonly) properties on the event, you're supposed to call the appropriate init...() method, which for the mouse event is initMouseEvent(). (spec)

Here's a fixed up testcase, which works in Firefox: http://jsfiddle.net/6nnMV/

Probably not useful to you, but may be of interest to other people looking to simulate events, here's how (privileged) unit tests in mozilla simulate 'real' events: http://hg.mozilla.org/mozilla-central/annotate/a666b4f809f0/testing/mochitest/tests/SimpleTest/EventUtils.js#l248

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!