scroll and mousewheel

Test page.

Events overview page.

These events allow you to monitor the user’s scolling.

scroll
Fires when the user scrolls an element by any means (arrow keys, scrollbar or mouse wheel). You cannot prevent the scrolling.
mousewheel
Fires when the user uses the mouse wheel. You can prevent this event’s default. Note that the page does not have to scroll in order to fire this event.

scroll

Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7
On the window
Yes Crash Yes Yes Minimal Yes No

Is the scroll event available on the window?

  • IE8b1 may crash after a while.
  • Opera allows registration on the window only when you use attachEvent.
On the document
No Yes Yes Yes No

Is the scroll event available on the document?

On any element with overflow: auto
Yes Crash Yes Buggy Yes No

Is the scroll event available on elements with overflow: auto?

  • IE8b1 may crash after a while.
  • Safari seems to monitor scrollTop acces in order to determine whether the user has scrolled an element. The log function of my test script changes scrollTop regularly, and Safari responds by firing a scroll event. Since the logging of this event changes the log element's scrollTop once more, scroll events will be fired continuously.
    All this happens when the log element at the bottom of the page doesn't have a scrollbar yet, when it has a normal overflow: visible, and even when I set scrollTop to 0 each time a new event is logged. The buggy behaviour stops only when I remove the scrollTop line entirely.
Event bubbling
“No” is the correct answer

The scroll event does not bubble up.

No No No Yes Incomplete Untestable

Note that the scroll event can be captured in FF3b4.

In Opera, and in FF3b4 when you use addEventListener in the capturing phase, once the log element at the bottom of the page gains a scrollbar, scroll events are fired continuously. The log gets a new entry, scrolls down, and fires a scroll event that passes the window/document level and is caught there, again resulting in a new entry that scrolls down the log.
The bug here is allowing the scroll event to reach the window/document level at all.

  • The event bubbles up incorrectly in Opera, with extra bugs:
    1. When using attachEvent registration, Opera fires the event on the window before the event on the document. (The event isn’t available on the window in any other registration.)
    2. When scrolling the div in Opera 9.5b, the event never bubbles up to the window level.
Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7

Mousewheel

Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7
On the window
No No Yes Minimal No

Is this event available on the window?

  • Opera allows registration on the window only when you use attachEvent.
On the document
No Yes No Yes Yes No

Is this event available on the document?

On any element with scrollbars
No Yes Untestable No Yes Yes Untestable

Is this event available on any element with scrollbars?

  • IE8b1 and Konqueror don't allow you to scroll the scrollable div by using the mouse wheel.
Bubbles

The mousewheel event should bubble up.

Untestable Yes Untestable Untestable Yes Almost Untestable
  • When using attachEvent registration, Opera fires the event on the window before the event on the document. (The event isn’t available on the window in any other registration.)
Cancel bubble

The bubbling can be canceled.

Untestable Yes Untestable Untestable Yes Yes Untestable
Prevent default

The default (scroll element) can be prevented.

Untestable Yes Untestable Yes Yes Untestable
Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7

Related events

Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7
DOMMouseScroll

When the user uses the mouse wheel.

Test page.

No Yes No No No

Equivalent of mousewheel.

Event IE 5.5 IE 6 IE 7 IE8b1 FF 2 FF 3b5 Saf 3.0 Win Saf 3.1 Win Opera 9.26 Opera 9.5b Konqueror 3.5.7