W3cubDocs

/Web APIs

Document: exitFullscreen() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The Document method exitFullscreen() requests that the element on this document which is currently being presented in fullscreen mode be taken out of fullscreen mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to Element.requestFullscreen().

Syntax

exitFullscreen()

Parameters

None.

Return value

A Promise which is resolved once the user agent has finished exiting fullscreen mode. If an error occurs while attempting to exit fullscreen mode, the catch() handler for the promise is called.

Examples

This example causes the current document to toggle in and out of a fullscreen presentation whenever the mouse button is clicked within it.

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();
  }
};

Note: For a more complete example, see the Element.requestFullscreen() examples.

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
exitFullscreen 7115 791212–14 649 581512.1–15 16.45.1 7118 649 501412.1–14
16.4["Only available on iPad, not on iPhone.", "Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games."]
12Only available on iPad, not on iPhone.
10.01.0 714.4 No
returns_promise 69 79 64 56 16.4 69 64 48 16.4 10.0 69 No

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen