W3cubDocs

/DOM

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().

The exception is if another element was already in full-screen mode when the current element was placed into full-screen mode using requestFullscreen(). In that case, the previous full-screen element is restored to full-screen status instead. In essence, a stack of full-screen elements is maintained.

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() 
  } 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 compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 45
45
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
12 64
64
49
Disabled
Disabled From version 49: 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.
9
Uses the non-standard name: mozCancelFullScreen
11
11
Uses the non-standard name: msExitFullscreen
15
Prefixed
15
Prefixed
Prefixed Implemented with the vendor prefix: webkit
5.1
Prefixed
5.1
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Returns a Promise 71 No 64 No ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support 45
45
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
45
45
Yes
Prefixed
Prefixed Implemented with the vendor prefix: webkit
? 64
64
49
Disabled
Disabled From version 49: 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.
9
Uses the non-standard name: mozCancelFullScreen
? No ?
Returns a Promise 71 71 No 64 ? ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/document/exitFullscreen