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 compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome 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
Full support 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.
Full support 9
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
Edge Mobile ? Firefox Android Full support 64
Full support 64
Full support 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.
Full support 9
Alternate Name
Alternate Name Uses the non-standard name: mozCancelFullScreen
Opera Android ? Safari iOS No support NoSamsung Internet Android ?
Returns a PromiseChrome Full support 71Edge No support NoFirefox Full support 64IE No support NoOpera ? Safari ? WebView Android Full support 71Chrome Android Full support 71Edge Mobile No support NoFirefox Android Full support 64Opera Android ? Safari iOS ? Samsung Internet Android ?

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

Document Tags and Contributors

Last updated by: mfuji09,