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.
exitPromise = document.exitFullscreen();
None.
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.
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().
| Specification | Status | Comment |
|---|---|---|
| Fullscreen API The definition of 'Document.exitFullscreen()' in that specification. | Living Standard | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 45
|
12 | 64
|
11
|
15
|
5.1
|
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
|
? | 64
|
? | No | ? |
Returns a Promise
|
71 | 71 | No | 64 | ? | ? | ? |
Element.requestFullscreen()Document.fullscreenElement:fullscreen and ::backdrop
<iframe> allowfullscreen attribute
© 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