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

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support

45

Yes webkit

?

91

492

? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support

45

Yes webkit

45

Yes webkit

?

91

492

? ? ?

1. Supported as mozCancelFullScreen.

2. 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.

See also

Document Tags and Contributors

Last updated by: fscholz,