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 form 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
Specification | Status | Comment |
---|---|---|
Fullscreen API The definition of 'Document.exitFullscreen()' in that specification. |
Living Standard | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
exitFullscreen | Chrome
Full support
45
| Edge Full support 12 | Firefox
Full support
64
| IE
Full support
11
| Opera
Full support
15
| Safari
Full support
5.1
| WebView Android
Full support
45
| Chrome Android
Full support
45
| Firefox Android
Full support
64
| Opera Android Full support Yes | Safari iOS No support No | Samsung Internet Android
Full support
5.0
|
Returns a Promise | Chrome Full support 71 | Edge Full support 79 | Firefox Full support 64 | IE No support No | Opera ? | Safari ? | WebView Android Full support 71 | Chrome Android Full support 71 | Firefox Android Full support 64 | Opera Android ? | Safari iOS No support No | Samsung Internet Android Full support 10.0 |
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.