The Document fullscreenerror event fires when the browser cannot switch to fullscreen. Learn why MDN delivers two events (Element, then Document), how to use document.onfullscreenerror, how it pairs with requestFullscreen() Promise rejection, and five try-it labs.
01
Kind
Document event
02
Type
Event
03
Cancelable
No
04
Delivery
Element, then Document
05
Also check
Promise .catch()
06
Status
Limited availability
Fundamentals
Introduction
Fullscreen is powerful—and often restricted. If requestFullscreen() is denied, the element does not go fullscreen. Instead you get a fullscreenerror event (and usually a rejected Promise).
Per MDN, twofullscreenerror events fire: the first on the Element that failed to change modes, and the second on the Document that owns that element. Listening on document is the natural place for app-wide error UI.
💡
Beginner tip
The most common beginner mistake is calling requestFullscreen() outside a click/key handler. Many browsers deny that and fire fullscreenerror. MDN marks this API Limited availability (not Baseline)—feature-detect and test.
Concept
Understanding fullscreenerror
A Document event that answers: “Did a fullscreen mode change fail?”
Fires when the browser cannot switch into (or sometimes out of) fullscreen.
Two deliveries — first to the Element, then to its Document (like fullscreenchange).
Not cancelable — you cannot force fullscreen by calling preventDefault().
Event type — a plain Event (no rich error code on the event itself).
Handler — document.onfullscreenerror or document.addEventListener("fullscreenerror", ...).
Limited availability on MDN (not Baseline)—test carefully.
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property on document:
Four facts to remember about Document fullscreenerror.
Event type
Event
Plain Event
Means
FS failed
Could not switch
Also
.catch()
Promise rejects
Baseline
no
Limited availability
Hands-On
Examples Gallery
Examples follow MDN Document: fullscreenerror event and listen on document. Some labs intentionally trigger failures (for example calling without a user gesture).
📚 Getting Started
MDN-style Document listener and the handler property.
Example 1 — Document addEventListener (MDN)
Log when a fullscreen mode change fails; listen on document.
JavaScript
const requestor = document.querySelector("div");
function handleError(event) {
console.error("an error occurred changing into fullscreen");
console.log(event);
}
document.addEventListener("fullscreenerror", handleError);
// or
document.onfullscreenerror = handleError;
requestor.requestFullscreen();
an error occurred changing into fullscreen
(Event object logged — request may fail without a user gesture)
How It Works
MDN’s sample calls requestFullscreen() immediately. In many browsers that fails; the Element gets the first error event, then Document gets the second—your Document listener still sees it.
Example 2 — document.onfullscreenerror
Update a status line when the Document handler property receives the event.
JavaScript
const el = document.getElementById("fs");
const out = document.getElementById("out");
document.onfullscreenerror = () => {
out.textContent = "fullscreenerror: could not change mode";
};
document.getElementById("bad").addEventListener("click", () => {
// Still may fail in some environments (iframe / policy)
el.requestFullscreen();
});
Document fullscreenerror is marked Limited availability on MDN (not Baseline). Logos use the shared browser-image-sprite.png sprite from this project. Feature-detect Fullscreen API methods, and remember iframes and permissions can still block fullscreen.
✓ Limited availability
Document fullscreenerror
Failure signal when fullscreen cannot start (or sometimes exit). Confirm support and permissions in your target browsers.
LimitedNot Baseline
Google ChromeSupported (check BCD / iframe policy)
Supported
Mozilla FirefoxSupported in modern versions
Supported
Apple SafariSupported with platform quirks
Supported
Microsoft EdgeSupported · Chromium
Supported
OperaSupported · Modern versions
Supported
Internet ExplorerNo modern Fullscreen API
No
fullscreenerrorLimited
Bottom line: Listen on document for fullscreenerror, also handle requestFullscreen().catch(), and always provide a non-fullscreen fallback.
Wrap Up
Conclusion
Document fullscreenerror is your safety net when fullscreen is denied. Listen on document for app-wide errors, catch the Promise too, and keep a usable windowed fallback ready.
Feature-detect and test iframes / Permissions Policy
❌ Don’t
Assume every browser / iframe allows fullscreen
Call enter fullscreen from a bare timer
Expect preventDefault() to force fullscreen
Ignore failures and leave the UI looking broken
Assume Baseline Widely available status
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about Document fullscreenerror
Failure signal (Element then Document) — always plan a fallback.
5
Core concepts
📄01
FS failed
could not switch
Event
🔁02
Two events
Element → Document
Path
📦03
Promise
also rejects
API
👋04
User gesture
required often
Cause
⚠️05
Limited avail.
not Baseline
Compat
❓ Frequently Asked Questions
It fires when the browser cannot switch to fullscreen mode. As with fullscreenchange, two fullscreenerror events are fired: first on the Element that failed, then on the Document that owns that element.
No. MDN does not mark Document fullscreenerror as Deprecated, Experimental, or Non-standard. It has Limited availability (not Baseline), so always test the browsers and embedding contexts you care about.
Common reasons: no user gesture, iframe without allow="fullscreen", Permissions Policy blocking fullscreen, unsupported content, or the browser denying permission. See MDN’s Fullscreen API guide.
No. MDN states this event is not cancelable. You cannot force fullscreen with preventDefault().
Either works. MDN’s Document example listens on document. That is handy for app-wide error UI because the second event delivery reaches Document.
Success path: requestFullscreen resolves and fullscreenchange fires. Failure path: the Promise rejects and fullscreenerror fires instead of a successful mode change.
Did you know?
MDN documents the same dual-delivery pattern for both fullscreenchange and fullscreenerror: Element first, Document second. That is why a single Document listener can power both success and failure UI for every fullscreen widget on the page.