JavaScript Element DOMMouseScroll Event

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Non-standard
Instance event

What You’ll Learn

The DOMMouseScroll event is a legacy Firefox scroll signal. Learn why it is Deprecated and Non-standard, how detail encodes direction, why preventDefault on this event alone is not enough, how to prefer wheel, and five try-it labs.

01

Kind

Instance event

02

Type

WheelEvent

03

When

Wheel / scroll gesture

04

Handler property

onDOMMouseScroll

05

Prefer

wheel

06

Status

Deprecated · Non-standard

Introduction

Before the web settled on one wheel API, browsers invented their own scroll events. Firefox used DOMMouseScroll (and related Gecko events). Other engines used names like mousewheel. That fragmentation made cross-browser zoom, custom scrollers, and “block default scroll” logic painful.

Today the portable answer is the standard wheel event. Use DOMMouseScroll only when reading or migrating old Firefox-specific code.

💡
Beginner tip

In Chrome, Safari, Edge, and most modern environments, a DOMMouseScroll listener will simply never run. Always demo wheel beside it so the lab still teaches something useful.

Understanding DOMMouseScroll

An instance event that answered: “Did the user operate a mouse wheel (or similar) enough to scroll about a line or a page?”

  • Deprecated & Non-standard on MDN — avoid in new projects.
  • Firefox-only historically — not a Chromium / WebKit event.
  • WheelEvent (MDN) — inherits from MouseEvent, UIEvent, and Event.
  • Listen with addEventListener("DOMMouseScroll", ...) or onDOMMouseScroll.
  • Replacement — the standardized wheel event.

📝 Syntax

Use the event name with addEventListener, or set the handler property:

JavaScript
addEventListener("DOMMouseScroll", (event) => { });

onDOMMouseScroll = (event) => { };

Event type

A WheelEvent (inherits from MouseEvent, UIEvent, and Event). Legacy docs may also mention the older MouseScrollEvent interface name.

Notable property: detail

Value ideaMeaning
Positive detailScrolling downward
Negative detailScrolling upward
+32768 / -32768Often page-down / page-up style scrolls
Other non-zero valuesUsually line counts (sign = direction)
0Trusted events never use 0 for detail

⚖️ DOMMouseScroll vs wheel

TopicDOMMouseScrollwheel
StatusDeprecated · Non-standardStandard (Baseline)
EnginesFirefox legacy pathAll modern browsers
Scroll dataMainly detail (lines / page codes)deltaX / deltaY / deltaZ + deltaMode
Block default scrollNot enough alone on modern GeckoUse preventDefault() on wheel
Use in new apps?NoYes
⚠️
preventDefault trap

On Gecko 17+, calling preventDefault() only on DOMMouseScroll is not enough to cancel every native wheel move. Small scrolls may fire other wheel events without DOMMouseScroll. Cancel the standard wheel event instead.

⚡ Quick Reference

GoalCode / note
Listen (legacy Firefox)el.addEventListener("DOMMouseScroll", fn)
Handler propertyel.onDOMMouseScroll = fn
Read directionevent.detail > 0 down · < 0 up
Modern replacementel.addEventListener("wheel", fn)
Block scrollingwheel + event.preventDefault() (not DOMMouseScroll alone)
MDN statusDeprecated · Non-standard

🔍 At a Glance

Four facts to remember about DOMMouseScroll.

Event type
WheelEvent

detail for direction

Means
wheel scroll

Firefox legacy

onDOMMouseScroll
yes

Handler property

Status
deprecated

+ Non-standard

Examples Gallery

Examples follow MDN Element: DOMMouseScroll event. Labs also attach wheel so they still teach portable scrolling when DOMMouseScroll never fires.

📚 Getting Started

Legacy listener forms and a portable wheel fallback.

Example 1 — addEventListener("DOMMouseScroll")

Log event.detail when the Firefox legacy event fires.

JavaScript
const box = document.getElementById("box");
const out = document.getElementById("out");

box.addEventListener("DOMMouseScroll", (event) => {
  out.textContent = "DOMMouseScroll detail=" + event.detail;
});
Try It Yourself

How It Works

Scroll over the box with a mouse wheel. If the label never updates, your browser likely does not dispatch DOMMouseScroll—use the wheel labs below.

Example 2 — onDOMMouseScroll Property

Same idea using the event handler property form.

JavaScript
const box = document.getElementById("box");
const out = document.getElementById("out");

box.onDOMMouseScroll = (event) => {
  out.textContent = "onDOMMouseScroll detail=" + event.detail;
};
Try It Yourself

How It Works

Prefer addEventListener in real apps (easier to add/remove multiple listeners). The property form is shown here because MDN documents it for this event.

📈 Fallback, Detail & Migrate

Dual-listen with wheel, interpret detail, ship the modern API.

Example 3 — Always Attach wheel Too

Teaching pattern: show which event actually fired in your browser.

JavaScript
const box = document.getElementById("box");
const out = document.getElementById("out");

box.addEventListener("DOMMouseScroll", () => {
  out.textContent = "Fired: DOMMouseScroll (legacy Firefox)";
});

box.addEventListener("wheel", () => {
  out.textContent = "Fired: wheel (portable)";
});
Try It Yourself

How It Works

Both may fire in some Firefox paths. For production, keep only the wheel listener.

Example 4 — Interpret detail Direction

Map positive / negative detail to “down” / “up” when the legacy event exists.

JavaScript
const box = document.getElementById("box");
const out = document.getElementById("out");

function describeDetail(detail) {
  if (detail === 32768) return "page down";
  if (detail === -32768) return "page up";
  if (detail > 0) return "down (" + detail + " lines)";
  if (detail < 0) return "up (" + detail + " lines)";
  return "unexpected detail=" + detail;
}

box.addEventListener("DOMMouseScroll", (event) => {
  out.textContent = "DOMMouseScroll: " + describeDetail(event.detail);
});

box.addEventListener("wheel", (event) => {
  const dir = event.deltaY > 0 ? "down" : event.deltaY < 0 ? "up" : "side/other";
  out.textContent = "wheel: " + dir + " (deltaY=" + event.deltaY + ")";
});
Try It Yourself

How It Works

Modern code should prefer deltaY (and friends) on wheel. The detail helpers exist so you can read old Firefox snippets with confidence.

Example 5 — Migrated Handler (Recommended)

The code you should ship: scrolling via wheel only.

JavaScript
const box = document.getElementById("box");
const out = document.getElementById("out");

box.addEventListener("wheel", (event) => {
  out.textContent =
    "wheel deltaY=" + event.deltaY +
    ", deltaMode=" + event.deltaMode;
});
Try It Yourself

How It Works

This is the migration target. Delete DOMMouseScroll listeners once your tests pass on wheel. To cancel scrolling, call preventDefault() on wheel (and ensure the listener is not passive if you need cancelable behavior).

🚀 Common Use Cases (Legacy Only)

  • Reading old Firefox documentation that mentions DOMMouseScroll.
  • Migrating legacy zoom / custom-scroll widgets that targeted Gecko only.
  • Interview questions comparing legacy wheel events vs standard wheel.
  • Understanding why blocking scroll needs wheel.preventDefault().
  • Recognizing related legacy names: MozMousePixelScroll, mousewheel.

🔧 How It Works (When Supported)

1

User operates a wheel / trackpad

Native scroll amount is delivered by the OS / browser.

Input
2

Accumulated scroll may exceed a line / page

Legacy Gecko then may fire DOMMouseScroll asynchronously.

Legacy
3

wheel also fires (modern path)

Your portable handler should live on wheel.

Modern
4

Migrate to wheel

Remove DOMMouseScroll once the modern path is verified.

📝 Notes

  • MDN: Deprecated & Non-standard — both status banners required before What You’ll Learn.
  • Not Experimental on the MDN Element page for this event.
  • Firefox-only historically; other engines never made this the portable API.
  • To cancel scrolling on modern Gecko, preventDefault() the wheel event.
  • Related learning: DOMActivate, focus, addEventListener(), JavaScript hub.

Limited / Legacy Support

DOMMouseScroll is marked Deprecated and Non-standard on MDN. Logos use the shared browser-image-sprite.png sprite from this project. Treat it as Firefox legacy only—always prefer wheel.

Deprecated · Non-standard

Element DOMMouseScroll

Do not rely on this event for new products. Use wheel for portable scroll and zoom UIs.

Legacy Firefox-era only
Google Chrome No DOMMouseScroll; use wheel
Use wheel
Mozilla Firefox Legacy / deprecated path only
Legacy
Apple Safari No DOMMouseScroll; use wheel
Use wheel
Microsoft Edge No DOMMouseScroll; use wheel
Use wheel
Opera Prefer wheel
Use wheel
Internet Explorer Different legacy wheel models; still prefer wheel polyfills / modern browsers
Legacy
DOMMouseScroll Deprecated

Bottom line: Listen for wheel in production. Use DOMMouseScroll only when studying or migrating old Firefox code.

Conclusion

DOMMouseScroll is a Deprecated, Non-standard Firefox scroll signal. Prefer the standardized wheel event for direction, deltas, and cancelable scroll control.

Continue with focus, addEventListener(), or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use addEventListener("wheel", ...) for new scroll / zoom logic
  • Dual-listen only while teaching or migrating legacy Firefox code
  • Cancel default scrolling via wheel + preventDefault()
  • Read deltaY / deltaMode instead of Firefox detail
  • Document why any remaining DOMMouseScroll listener exists

❌ Don’t

  • Ship new features that depend only on DOMMouseScroll
  • Assume Chromium or Safari will fire this event
  • Rely on preventDefault() of DOMMouseScroll alone
  • Treat detail === 0 as a normal trusted value
  • Skip a wheel fallback in demos

Key Takeaways

Knowledge Unlocked

Five things to remember about DOMMouseScroll

Deprecated Firefox wheel event—Non-standard; migrate to wheel.

5
Core concepts
📄 02

WheelEvent

detail direction

API
🖥️ 03

Firefox-only

not portable

Limit
🔄 04

Prefer wheel

deltaY & friends

Replace
🎯 05

Cancel via wheel

preventDefault

Gotcha

❓ Frequently Asked Questions

It is a legacy Firefox (Gecko) event fired when the mouse wheel (or similar device) scrolls enough to accumulate more than about one line or one page since the last event. MDN marks it Deprecated and Non-standard.
It is Deprecated and Non-standard on MDN. It is not marked Experimental. Prefer the standard wheel event in all new code.
Historically Firefox only. Chrome, Safari, Edge, and other engines do not implement this Firefox-specific event. Always use wheel for portable apps.
Positive detail means scrolling down; negative means up. Line counts use other values; page-up is often -32768 and page-down +32768. Trusted events never use detail 0.
No — not reliably. On modern Firefox you must call preventDefault() on the standard wheel event, because small native wheel moves may not produce DOMMouseScroll.
Use the standardized wheel event (WheelEvent). It works across browsers and exposes deltaX, deltaY, deltaZ, and deltaMode.
Did you know?

Firefox also had a related legacy pixel-scroll event named MozMousePixelScroll. Non-Gecko engines historically used mousewheel. All of those paths converge on the standardized wheel event today.

Next: focus

Learn when an element receives focus—and how focusin helps with delegation.

focus →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful