document.exitFullscreen() is an instance method that asks the browser to leave fullscreen mode (see MDN Document: exitFullscreen()). Learn its Promise return, how it pairs with Element.requestFullscreen() and fullscreenElement, fullscreenchange events, feature detection, and five try-it labs.
01
Kind
Instance method
02
Params
None
03
Returns
Promise
04
Reverses
requestFullscreen
05
Check with
fullscreenElement
06
Status
Limited availability
Fundamentals
Introduction
Fullscreen mode fills the screen with one element — often a video player, slideshow, or game canvas. You enter with element.requestFullscreen(). To leave from script, call document.exitFullscreen().
MDN: this method requests that the element currently presented in fullscreen be taken out of fullscreen, restoring the previous screen state. It usually reverses a previous requestFullscreen() call.
💡
Think: exit door for fullscreen
1) Check document.fullscreenElement 2) If set, call document.exitFullscreen() 3) Await the Promise (or use .then() / .catch()) 4) Update UI on fullscreenchange
An instance method on the page’s document object (Fullscreen API; MDN).
Parameters — none (MDN).
Return value — a Promise that resolves when exiting finishes (MDN).
Errors — if exiting fails, the promise rejects; handle with catch() (MDN).
Pair — enter with Element.requestFullscreen(); exit with this method.
Status check — read document.fullscreenElement (or listen for fullscreenchange).
User exit — Esc / system UI can also leave fullscreen without your call.
Foundation
📝 Syntax
General form of Document.exitFullscreen (MDN):
JavaScript
exitFullscreen()
Parameters
None (MDN).
Return value
A Promise resolved once the user agent has finished exiting fullscreen. On failure, use the promise’s catch() handler (MDN).
MDN toggle example
JavaScript
document.onclick = (event) => {
if (document.fullscreenElement) {
document
.exitFullscreen()
.then(() => console.log("Document Exited from Full screen mode"))
.catch((err) => console.error(err));
} else {
document.documentElement.requestFullscreen();
}
};
MDN notes a more complete demo lives with Element.requestFullscreen() examples. Entering fullscreen normally needs a user gesture (click / tap).
Compare
⚖️ Fullscreen API pieces
API
Role
Typical use
element.requestFullscreen()
Enter
Put that element fullscreen
document.exitFullscreen()
Exit
Leave fullscreen from script
document.fullscreenElement
Status
Which element is fullscreen, or null
document.fullscreenEnabled
Capability
Is fullscreen allowed in this context?
fullscreenchange
Event
Update UI when mode changes
Cheat Sheet
⚡ Quick Reference
Goal
Code
Exit fullscreen
await document.exitFullscreen()
Exit with handlers
document.exitFullscreen().then(...).catch(...)
Only if active
if (document.fullscreenElement) { ... }
Enter first
await el.requestFullscreen()
Feature-detect
typeof document.exitFullscreen === "function"
MDN status
Limited availability (not Baseline)
Snapshot
🔍 At a Glance
Four facts about document.exitFullscreen().
Returns
Promise
async exit
Params
none
MDN
Guard
fullscreenElement
check first
Status
limited
Not Baseline
Compare
📋 Script exit vs user Esc
exitFullscreen()
Esc / system UI
Who starts it?
Your script
The user / OS
Promise?
Yes — resolve / reject (MDN)
No script Promise
UI sync
Still listen for fullscreenchange
Same event fires
Best practice
Guard with fullscreenElement
Do not assume only your Exit button leaves
Hands-On
Examples Gallery
Examples follow MDN Document: exitFullscreen() and practical Fullscreen API patterns. Embedded try-it frames may block fullscreen — open labs in a full tab when testing enter/exit.
📚 Getting Started
Toggle in and out of fullscreen like MDN’s sample.
Example 1 — MDN: click to toggle fullscreen
If already fullscreen, exit; otherwise request fullscreen on documentElement.
JavaScript
document.onclick = () => {
if (document.fullscreenElement) {
document
.exitFullscreen()
.then(() => console.log("Document Exited from Full screen mode"))
.catch((err) => console.error(err));
} else {
document.documentElement.requestFullscreen();
}
};
Document.exitFullscreen() is marked Limited availability on MDN (not Baseline). Feature-detect before production use. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Limited availability · Not Baseline
Document.exitFullscreen()
Leave fullscreen with a Promise — pair with requestFullscreen, fullscreenElement, and fullscreenchange.
LimitedCheck compat
Google ChromeWidely supported · Desktop & Mobile
Supported
Mozilla FirefoxSupported in modern versions
Supported
Apple SafariSupported with Fullscreen API
Supported
Microsoft EdgeChromium support
Supported
OperaFollow Chromium behavior
Supported
Internet ExplorerNot modern Fullscreen API
No / legacy only
Document.exitFullscreen()Limited availability
Bottom line: Call exitFullscreen when fullscreenElement is set. Handle the Promise, listen for fullscreenchange, and feature-detect for Limited availability.
Wrap Up
Conclusion
document.exitFullscreen() is the Fullscreen API’s exit door: no parameters, a Promise, and a restored window after a successful leave. Guard with fullscreenElement, catch rejections, and keep UI honest with fullscreenchange.
Enter fullscreen only from a user gesture when calling requestFullscreen
❌ Don’t
Assume Baseline support in every browser yet (MDN: Limited availability)
Ignore promise rejections when exit fails
Rely on deprecated document.fullscreen for status
Forget Esc can exit without your Exit button
Expect fullscreen to work inside every iframe without permissions
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about exitFullscreen()
Leave fullscreen with a Promise; sync UI on change.
5
Core concepts
📝01
Returns
Promise
MDN
🔄02
Params
none
MDN
📄03
Guard
fullscreenElement
check
⚡04
Pair
requestFullscreen
enter
🛡05
Status
Limited
not Baseline
❓ Frequently Asked Questions
MDN: Document.exitFullscreen() requests that the element currently presented in fullscreen mode be taken out of fullscreen, restoring the previous screen state. It usually reverses Element.requestFullscreen().
No. MDN does not mark Document.exitFullscreen() as Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline), so feature-detect in production.
A Promise that resolves when the user agent has finished exiting fullscreen. If exiting fails, the promise rejects and you can handle it with catch() (MDN).
No. MDN: exitFullscreen() has no parameters.
Check document.fullscreenElement. If it is non-null, an element is in fullscreen and exitFullscreen() can leave that mode.
Yes. Esc and system UI can leave fullscreen. Listen for the fullscreenchange event so your UI stays in sync whether exit came from script or the user.
Did you know?
You exit fullscreen on the Document, but you enter it on an Element via requestFullscreen(). That split is why status lives on document.fullscreenElement — one place to ask “who owns the screen right now?”