JavaScript Document releaseCapture() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

document.releaseCapture() turns off mouse capture if it is active on an element in this document. After release, mouse events stop being redirected to that element. Capture is enabled with element.setCapture().

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call document.releaseCapture. Start with this line.

JavaScript
document.releaseCapture()
CallWhat it does
document.releaseCapture()Primary signature.
document.releaseCapture(...)Call with the arguments your case needs.

Built into the browser. Call releaseCapture(...) on document — no import required.

Library declarations
JavaScript
document.releaseCapture()

Parameters

This member has no parameters beyond those shown in the signature.

Return Value

Return ValueDescription
*Always undefined

JavaScript Examples

Example 1 — Feature-Detect releaseCapture

Most modern browsers omit this API — check before you call it.

JavaScript
const hasApi = typeof document.releaseCapture === "function";
console.log("releaseCapture available:", hasApi);

if (!hasApi) {
  console.log("Use Pointer Events capture instead");
}
Try It Yourself

How It Works

  1. Test the method. typeof … === "function" avoids a crash when missing.
  2. Log the result. Useful when comparing browsers or teaching support gaps.
  3. Plan a fallback. If absent, steer code toward Pointer Events.
  4. Why it matters. Non-standard APIs are often missing outside a few engines.

Example 2 — Safe Call When Present

Call releaseCapture() only after detecting it. Return value is undefined.

JavaScript
function releaseMouseCapture() {
  if (typeof document.releaseCapture !== "function") {
    return "missing";
  }
  const result = document.releaseCapture();
  return String(result); // "undefined"
}

console.log(releaseMouseCapture());
Try It Yourself

How It Works

  1. Guard the call. Return early when the function is not there.
  2. Invoke with no args. MDN: no parameters.
  3. Expect undefined. There is no boolean success flag.
  4. Safe when idle. Calling with no active capture is typically a no-op in supporting engines.

Example 3 — Prefer Pointer Events Capture

MDN points new work at setPointerCapture / releasePointerCapture.

JavaScript
const el = document.getElementById("pad");

const hasLegacy =
  typeof document.releaseCapture === "function" &&
  typeof el.setCapture === "function";

const hasPointer =
  typeof el.setPointerCapture === "function" &&
  typeof el.releasePointerCapture === "function";

console.log("legacy capture:", hasLegacy);
console.log("pointer capture:", hasPointer);
// Prefer pointer capture for new drag UX
Try It Yourself

How It Works

  1. Pick a target element. Capture APIs live on the element you drag from.
  2. Detect the legacy pair. Needs both setCapture and releaseCapture.
  3. Detect Pointer Events. Check setPointerCapture / releasePointerCapture.
  4. Choose modern. For new products, ship the Pointer Events path.

Browser Support

Document.releaseCapture() is a legacy browser DOM API. MDN marks it Non-standard (not part of any specification). Support is limited; always feature-detect.

✓ Non-standard

Document.releaseCapture()

Legacy mouse-capture release — historically tied to Element.setCapture(); prefer Pointer Events.

Limited Feature-detect required
Google Chrome Not typically available
No
Microsoft Edge Not typically available
No
Mozilla Firefox Historic / limited legacy path
Legacy
Apple Safari Not typically available
No
Opera Follow Chromium — usually absent
No
Internet Explorer Historic mouse capture path
Legacy
releaseCapture() Avoid for new code

Bottom line: Learn it for legacy / interview context. For new drag and pointer UX, use setPointerCapture / releasePointerCapture. See the MDN Document.releaseCapture() reference.

Frequently Asked Questions

It releases mouse capture if capture is currently enabled on an element in this document. After release, mouse events are no longer all directed to that capturing element.
MDN marks Document.releaseCapture() as Non-standard (not part of any specification). The paired Element.setCapture() is marked Deprecated and Non-standard. Prefer Pointer Events for new code.
Call element.setCapture() (usually during mousedown). Document.releaseCapture() turns that capture off.
undefined. There are no parameters.
Use the Pointer Events API: element.setPointerCapture(pointerId) and element.releasePointerCapture(pointerId). MDN warns the old setCapture / releaseCapture pair never had much cross-browser support.
In supporting engines it is typically a safe no-op when capture is not active. Always feature-detect first — many modern browsers do not implement Document.releaseCapture().

Next: replaceChildren()

Learn how to replace all children of a Document in one call.

replaceChildren() 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.

9 people found this page helpful