Document.exitFullscreen()

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

Syntax

exitPromise = document.exitFullscreen();

Parameters

None.

Return value

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

Example

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

document.onclick = function (event) {
  if (document.fullscreenElement) {
    document.exitFullscreen()
      .then(() => console.log("Document Exited form Full screen mode"))
      .catch((err) => console.error(err))
  } else {
    document.documentElement.requestFullscreen();
  }
}

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

Specifications

Specification Status Comment
Fullscreen API
The definition of 'Document.exitFullscreen()' in that specification.
Living Standard Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
exitFullscreenChrome Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 64
Full support 64
No support 49 — 65
Disabled
Disabled From version 49 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 9 — 65
Alternate Name
Alternate Name Uses the non-standard name: mozCancelFullScreen
IE Full support 11
Alternate Name
Full support 11
Alternate Name
Alternate Name Uses the non-standard name: msExitFullscreen
Opera Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari Full support 5.1
Prefixed
Full support 5.1
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Full support 64
Full support 64
No support 49 — 65
Disabled
Disabled From version 49 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.
No support 9 — 65
Alternate Name
Alternate Name Uses the non-standard name: mozCancelFullScreen
Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 5.0
Full support 5.0
Full support Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Returns a PromiseChrome Full support 71Edge Full support 79Firefox Full support 64IE No support NoOpera ? Safari ? WebView Android Full support 71Chrome Android Full support 71Firefox Android Full support 64Opera Android ? Safari iOS No support NoSamsung Internet Android Full support 10.0

Legend

Full support
Full support
No support
No support
Compatibility unknown
Compatibility unknown
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also