JavaScript Element DOMActivate Event

Beginner
5 min read
Updated: Nov 2026
3 examples
Event

Definition

In JavaScript, the DOMActivate event fires when an element becomes active — for example when it is clicked with the mouse or activated with a keypress (MDN).

Register a listener with addEventListener. Check readiness and browser support before you rely on this event.

Syntax

Listen for DOMActivate. Start with this line.

JavaScript
addEventListener("DOMActivate", fn)
CallWhat it does
addEventListener("DOMActivate", fn)Primary signature.

Built into the browser. Listen with el.addEventListener("DOMActivate", …) — no import required.

Library declarations
JavaScript
addEventListener("DOMActivate", fn)

Parameters

ParameterDescription
Event nameRequired. "DOMActivate" (case-sensitive)

Return Value

Return ValueDescription
*Fires as an Element event (listener receives the Event object).

JavaScript Examples

Example 1 — Show detail (MDN)

Legacy demo: update the button text from event.detail.

JavaScript
const button = document.querySelector("button");

button.addEventListener("DOMActivate", (event) => {
  button.textContent = "Click count: " + event.detail;
});
Try It Yourself

How It Works

  1. Listen with addEventListener only. There is no onDOMActivate (MDN).
  2. Read event.detail. It may always be 0, or track consecutive clicks.
  3. Update the label. Matches MDN’s teaching demo.
  4. Expect silence. Some browsers never fire this Deprecated event.

Example 2 — Compare DOMActivate with click

Log both so you can see which one your browser still dispatches.

JavaScript
const button = document.getElementById("btn");
const out = document.getElementById("out");

button.addEventListener("DOMActivate", () => {
  out.textContent += "DOMActivate fired\\n";
});

button.addEventListener("click", () => {
  out.textContent += "click fired\\n";
});
Try It Yourself

How It Works

  1. Attach both listeners. Same activation gesture can produce different events.
  2. Activate the button. Mouse click or keyboard Enter/Space.
  3. Read the log. click is the reliable signal today.
  4. Treat missing DOMActivate as normal for a Deprecated API.

Example 3 — Prefer click (Recommended)

The modern replacement for activation logic in new projects.

JavaScript
const button = document.querySelector("button");

button.addEventListener("click", () => {
  button.textContent = "Activated with click";
});
Try It Yourself

How It Works

  1. Listen for click. Standard activation for buttons and links.
  2. Run your logic there. Mouse, touch, and keyboard activate share this path.
  3. Skip DOMActivate. MDN: avoid Deprecated features in new projects.
  4. Migrate old code by renaming the event string to "click".

Browser Support

Element DOMActivate is marked Deprecated on MDN. Do not add it to new code — migrate to click. Support is incomplete and shrinking.

✓ Deprecated

DOMActivate

Legacy UIEvent when an element becomes active — study only, prefer click.

— Deprecated
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
DOMActivate Deprecated

Bottom line: Use addEventListener only (no onDOMActivate). Prefer click for mouse, touch, and keyboard activation.

Frequently Asked Questions

It fires when an element becomes active — for example when it is clicked with the mouse or activated with a keypress (MDN). Prefer the standard click event in new code.
MDN marks Element DOMActivate as Deprecated only — not Experimental and not Non-standard. Avoid it in new projects; it may be removed from standards or browsers.
No. MDN states there is no onDOMActivate event handler property. Use addEventListener("DOMActivate", …) only if you must support legacy code.
A UIEvent (inherits from Event). The detail property may always be 0, or behave like click’s detail (click count), depending on the browser (MDN).
Prefer the standard click event for activation. It works with mouse, many touch gestures, and keyboard activation on buttons and links.
Some modern browsers no longer dispatch it. Treat missing events as expected for a Deprecated API — migrate to click.

Next: DOMMouseScroll

Learn another legacy scroll-related event and what to use instead.

DOMMouseScroll tutorial →

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.

11 people found this page helpful