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 from 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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
exitFullscreen
71
15
79
12
12-14
64
9
11
58
15
12.1-15
5.1
71
≤37
71
18
64
9
50
14
12.1-14
12
Only available on iPad, not on iPhone.
10.0
1.0
returns_promise
69
79
64
No
?
No
69
69
64
?
No
10.0

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Document/exitFullscreen