弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。
obsolete
and
non-standard
mousewheel
event is fired asynchronously at an
元素
to provide updates while a mouse wheel or similar device is operated. The
mousewheel
event was never part of any standard, and while it was implemented by several browsers, it was never implemented by Firefox.
重要:
Instead of this obsolete event, use the standard
wheel
事件。
| 冒泡 | Yes |
|---|---|
| 可取消 | Yes |
| 接口 |
MouseWheelEvent
|
| 事件处理程序特性 |
onmousewheel
|
值对于
detail
property is always zero, except in Opera, which uses
detail
similarly to the Firefox-only
DOMMouseScroll
event's
detail
value, which indicates the scroll distance in terms of lines, with negative values indicating the scrolling movement is either toward the bottom or toward the right, and positive values indicating scrolling to the top or left.
注意:
On macOS, the scroll distance (and therefore the value of
detail
) is computed based on the accelerated scroll distance.
在 Linux,
2
or
-2
is set per native wheel event.
wheelDelta
attribute value is an abstract value which indicates how far the wheel turned. If the wheel has rotated away from the user, it's positive, otherwise negative. This means that the delta value sign is different from DOM Level 3 Event's
wheel
. However, the meaning of the amount of these values is not the same between browsers. See following explanation for the detail.
IE and Opera (Presto) only support
wheelDelta
attribute and do
not
support horizontal scroll.
wheelDeltaX
attribute value indicates the
wheelDelta
attribute value along the horizontal axis. When a user operates the device for scrolling to right, the value is negative. Otherwise, i.e., if it's to left, the value is positive.
wheelDeltaY
attribute value indicates the
wheelDelta
attribute value along the vertical axis. The sign of the value is the same as the
wheelDelta
attribute value.
The value is the same as the delta value of Windows'
WM_MOUSEWHEEL
or
WM_MOUSEHWHEEL
. It means that if the mouse wheel doesn't support high resolution scroll, the value is 120 per notch. The value isn't changed even if the scroll amount of system settings is page scroll.
On Windows, the value is the same as the delta value of
WM_MOUSEWHEEL
or
WM_MOUSEHWHEEL
. And also, the value isn't changed even if the scroll amount of system settings is page scroll, i.e., the value is the same as IE on Windows.
On Linux, the value is
120
or
-120
per native wheel event. This makes the same behavior as IE and Chrome for Windows.
On Mac, the value is complicated. The value is changed if the device that causes the native wheel event supports continuous scroll.
If the device supports continuous scroll (e.g., trackpad of MacBook or mouse wheel which can be turned smoothly), the value is computed from accelerated scroll amount. In this case, the value is the same as Safari.
If the device does not support continuous scroll (typically, old mouse wheel which cannot be turned smoothly), the value is computed from non-accelerated scroll amount (120 per notch). In this case, the value is different from Safari.
This difference makes a serious issue for web application developers. That is, web developers cannot know if
mousewheel
event is caused by which device.
见
WebInputEventFactory::mouseWheelEvent
的
Chromium's source code
for the detail.
The value is always computed from accelerated scroll amount. This is really different from other browsers except Chrome with continuous scroll supported device.
The value is always the
detail
attribute value ✕
40
.
On Windows, since the
detail
attribute value is computed from actual scroll amount, the value is different from other browsers except the scroll amount per notch is 3 lines in system settings or a page.
On Linux, the value is
80
or
-80
per native wheel event. This is different from other browsers.
On Mac, the
detail
attribute value is computed from accelerated scroll amout of native event. The value is usually much bigger than Safari's or Chrome's value.
Not part of any specification.
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mousewheel
event
弃用
非标
|
Chrome 31 | Edge ≤79 | Firefox No | IE ? | Opera ? | Safari ? | WebView Android ? | Chrome Android ? | Firefox Android No | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
完整支持
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
MouseWheelEvent
DOMMouseScroll
,
MozMousePixelScroll
wheel
元素
accessKey
属性
childElementCount
children
classList
className
clientHeight
clientLeft
clientTop
clientWidth
currentStyle
firstElementChild
id
innerHTML
lastElementChild
localName
名称
namespaceURI
nextElementSibling
onfullscreenchange
onfullscreenerror
openOrClosedShadowRoot
outerHTML
part
prefix
previousElementSibling
runtimeStyle
scrollHeight
scrollLeft
scrollLeftMax
scrollTop
scrollTopMax
scrollWidth
shadowRoot
slot
tabStop
tagName
after()
animate()
append()
attachShadow()
before()
closest()
computedStyleMap()
createShadowRoot()
getAnimations()
getAttribute()
getAttributeNames()
getAttributeNode()
getAttributeNodeNS()
getAttributeNS()
getBoundingClientRect()
getClientRects()
getElementsByClassName()
getElementsByTagName()
getElementsByTagNameNS()
hasAttribute()
hasAttributeNS()
hasAttributes()
hasPointerCapture()
insertAdjacentElement()
insertAdjacentHTML()
insertAdjacentText()
matches()
msZoomTo()
prepend()
querySelector()
querySelector()
querySelectorAll()
querySelectorAll()
releasePointerCapture()
remove()
removeAttribute()
removeAttributeNode()
removeAttributeNS()
replaceChildren()
replaceWith()
requestFullscreen()
requestPointerLock()
scroll()
scrollBy()
scrollIntoView()
scrollIntoViewIfNeeded()
scrollTo()
setAttribute()
setAttributeNode()
setAttributeNodeNS()
setAttributeNS()
setCapture()
setPointerCapture()
toggleAttribute()
afterscriptexecute
auxclick
blur
click
compositionend
compositionstart
compositionupdate
contextmenu
copy
cut
dblclick
DOMActivate
DOMMouseScroll
error
focus
focusin
focusout
fullscreenchange
fullscreenerror
gesturechange
gestureend
gesturestart
keydown
keypress
keyup
mousedown
mouseenter
mouseleave
mousemove
mouseout
mouseover
mouseup
mousewheel
MozMousePixelScroll
msContentZoom
MSGestureChange
MSGestureEnd
MSGestureHold
MSGestureStart
MSGestureTap
MSInertiaStart
MSManipulationStateChanged
overflow
paste
scroll
select
show
touchcancel
touchend
touchmove
touchstart
underflow
webkitmouseforcechanged
webkitmouseforcedown
webkitmouseforceup
webkitmouseforcewillbegin
wheel