The Document.exitFullscreen() is a method that takes the document out of full-screen mode; this is used to reverse the effects of a call to make an element in the document full-screen using its Element.requestFullscreen() method.

Note: If another element was previously in full-screen mode when the current element was placed into full-screen mode, that previous element regains full-screen mode. A "stack" of full-screen elements is maintained by the browser for this purpose.

Syntax

document.exitFullscreen();

Example

// Click toggle fullscreen mode
document.onclick = function (event) { 
  if (document.fullscreenElement) { 
    document.exitFullscreen() 
  } else { 
    document.documentElement.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 AndroidiOS SafariSamsung Internet
Basic support
Experimental
Chrome Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Requires 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
Prefixed
Full support 11
Prefixed
Prefixed Requires the vendor prefix: ms
Opera Full support 15
Prefixed
Full support 15
Prefixed
Prefixed Requires the vendor prefix: webkit
Safari Full support 5.1
Prefixed
Full support 5.1
Prefixed
Prefixed Requires the vendor prefix: webkit
WebView Android Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Requires the vendor prefix: webkit
Chrome Android Full support 45
Full support 45
Full support Yes
Prefixed
Prefixed Requires 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 Promise
Experimental
Chrome ? Edge ? Firefox Full support 64IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 64Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
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: fscholz,