Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

DOMMouseScroll

非标准

The DOM DOMMouseScroll event is fired asynchronously when mouse wheel or similar device is operated and the accumulated scroll amount becomes over 1 line or 1 page since last event. It's represented by the MouseScrollEvent interface.

If you want to prevent the default action of mouse wheel events, it's not enough to handle only this event on Gecko because If scroll amount by a native mouse wheel event is less than 1 line (or less than 1 page when the system setting is by page scroll), other mouse wheel events may be fired without this event.

On Gecko 17 (Firefox 17) or later, you need to call prevnetDefault() of wheel events which must be fired for every native event.

On Gecko 16 or earlier, you need to call preventDefault() of MozMousePixelScroll event which must be fired for every native event.

Use standardized wheel event if available.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support Not supported Unknown (0.9.7) Not supported Not supported Not supported
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support Not supported 0.0 (0.9.7) Not supported Not supported Not supported

detail value

When the event causes scroll up by a page, the detail value is -32768. When the event causes scroll down by a page, the value is 32768. Otherwise, scroll amount in lines.

Trusted events are never fired with 0.

If native mouse wheel event indicates the scroll amount only in pixels or scroll speed is customized by user prefs, the value is computed with the line height of the nearest ancestor element which is scrollable. If the font size is smaller than "mousewheel.min_line_scroll_amount", using the pref value as the line height.

See also

文档标签和贡献者

 此页面的贡献者: ziyunfei
 最后编辑者: ziyunfei,