document.releaseCapture() is a Non-standard instance method that turns off mouse capture for the document (see MDN Document: releaseCapture()). Learn how it pairs with element.setCapture(), how to feature-detect safely, and why modern apps use Pointer Events instead — plus five try-it labs.
01
Kind
Instance method
02
Args
None
03
Returns
undefined
04
Pairs with
setCapture()
05
Prefer
Pointer Events
06
Status
Non-standard
Fundamentals
Introduction
Sometimes a drag or slider needs every mouse move — even when the pointer leaves the element. Older Gecko-oriented APIs solved that with mouse capture: call element.setCapture() on mousedown, then later call document.releaseCapture() to restore normal event targeting (MDN).
MDN: once capture is released, mouse events will no longer all be directed to the element that held capture. There are no parameters; the return value is undefined.
💡
Think: “Stop routing all mouse events to that element”
1) mousedown → el.setCapture() (Non-standard) 2) Mouse moves keep targeting that element 3) document.releaseCapture() (or mouseup / button up) ends capture 4) New code: use setPointerCapture(pointerId) instead (MDN advice)
⚠️
Learning only — not for production
MDN recommends against non-standard features in production. The setCapture / releaseCapture pair never had strong cross-browser support. Feature-detect, then teach the Pointer Events replacement.
An instance method on Document (MDN). It is not standardized.
Parameters — none (MDN).
Returns — undefined (MDN).
Effect — releases mouse capture if an element in this document currently has it (MDN).
Enable side — element.setCapture() (MDN); that Element method is Deprecated & Non-standard.
Modern replacement — Element.setPointerCapture() / releasePointerCapture() (MDN).
Spec — not part of any specification (MDN).
Foundation
📝 Syntax
General form of Document.releaseCapture (MDN):
JavaScript
releaseCapture()
Parameters
None (MDN).
Return value
None (undefined) (MDN).
Enable capture (related API)
JavaScript
// Non-standard / Deprecated on Element (MDN)
element.setCapture();
// optional: element.setCapture(true); // retarget all events to this element
MDN-style pair
JavaScript
function mouseDown(e) {
if (typeof e.target.setCapture === "function") {
e.target.setCapture();
}
e.target.addEventListener("mousemove", mouseMoved);
}
function mouseUp(e) {
if (typeof document.releaseCapture === "function") {
document.releaseCapture();
}
e.target.removeEventListener("mousemove", mouseMoved);
}
Compare
⚖️ releaseCapture vs Pointer Events
document.releaseCapture()
el.releasePointerCapture()
Spec status
Non-standard (MDN)
Standard Pointer Events
Enable API
element.setCapture() (Deprecated + Non-standard)
element.setPointerCapture(pointerId)
Args
None
pointerId from the pointer event
Cross-browser
Narrow / legacy
Wide modern support
Production?
No (MDN advice)
Yes
Cheat Sheet
⚡ Quick Reference
Goal
Code / note
Feature-detect
typeof document.releaseCapture === "function"
Release capture
document.releaseCapture()
Enable (legacy)
element.setCapture() on mousedown (MDN)
Modern enable
el.setPointerCapture(e.pointerId)
Modern release
el.releasePointerCapture(e.pointerId)
MDN status
Non-standard — not in any specification
Snapshot
🔍 At a Glance
Four facts about document.releaseCapture().
Returns
undefined
MDN
Args
none
MDN
Pairs
setCapture
Element
Status
Non-std
MDN
Compare
📋 When capture starts and ends
Situation
What happens
Tip
After setCapture()
Mouse events retarget to that element until release (MDN)
Usually call during mousedown
After releaseCapture()
Normal targeting resumes (MDN)
Call on mouseup or cancel
Mouse button released
Capture often ends automatically in supporting engines
Still call release for clarity in demos
Unsupported browser
Method missing
Feature-detect; use Pointer Events
Hands-On
Examples Gallery
Examples follow MDN Document: releaseCapture() and the related Element.setCapture() demo. Open try-it labs in a supporting engine (historically Firefox) to feel capture; elsewhere the labs show safe feature-detection messages.
📚 Getting Started
Detect support and understand the setCapture / releaseCapture pair.
Example 1 — Feature-detect first
Non-standard APIs must be checked before every call.
Document.releaseCapture() is Non-standard on MDN and is not part of any specification. Historical support was engine-specific (notably Gecko-oriented mouse capture). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Non-standard ยท Limited
Document.releaseCapture()
Release legacy mouse capture enabled by element.setCapture(). Feature-detect and prefer Pointer Events for production.
LimitedNon-standard
Mozilla FirefoxLegacy mouse capture
Limited
Google ChromeUse Pointer Events
No
Microsoft EdgeUse Pointer Events
No
Apple SafariUse Pointer Events
No
OperaUse Pointer Events
No
Internet ExplorerRelated Element APIs
Legacy
releaseCapture()Narrow
Bottom line: Use only for legacy literacy. Ship Element.setPointerCapture() / releasePointerCapture() for real drag and slider UX.
Wrap Up
Conclusion
document.releaseCapture() is a Non-standard way to end mouse capture that was started with element.setCapture(). Learn the MDN pair for literacy, then build new interactions with Pointer Events capture APIs.
Pair release with the same gesture that called setCapture
Document Non-standard status in any legacy notes
❌ Don’t
Depend on it for production UX (MDN)
Assume Chrome / Safari implement it
Skip feature detection
Confuse Non-standard mouse capture with pointer lock
Ignore the Pointer Events migration path
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about releaseCapture()
Non-standard Document mouse-capture release.
5
Core concepts
📝01
Returns
undefined
MDN
🔄02
Args
none
MDN
🎯03
Pairs
setCapture
Element
⚡04
Prefer
Pointer Events
modern
🛡05
Status
Non-std
MDN
❓ Frequently Asked Questions
MDN: Document.releaseCapture() releases mouse capture if it is currently enabled on an element within this document. After release, mouse events are no longer all directed to the capturing element.
MDN marks Document.releaseCapture() as Non-standard. It is not part of any specification. It is not marked Deprecated or Experimental on the Document page. Prefer Element.setPointerCapture() / releasePointerCapture() for new code.
MDN: enabling mouse capture is done by calling element.setCapture(). Document.releaseCapture() turns that capture off.
None (undefined) (MDN). There are no parameters.
MDN warns that the old setCapture / releaseCapture pair never had much cross-browser support. Use the Pointer Events API: element.setPointerCapture(pointerId) and element.releasePointerCapture(pointerId).
In supporting engines it is typically a safe no-op when capture is not active. Always feature-detect first because most modern browsers do not implement Document.releaseCapture().
Did you know?
MDN’s Document page for releaseCapture() does not include its own live demo — it points you to the Element.setCapture() examples instead, because capture must be enabled before it can be released.