Fullscreen API
The Document method exitFullscreen() requests that the element on this document which is currently being presented in fullscreen mode be taken out of fullscreen mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to Element.requestFullscreen().
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 71 | 12 | 64 | 16.4 | 71 | 16.4 | |
| HTML attribute | ||||||
allow (fullscreen) | 62 | 79 | 80 | | 62 | |
allowfullscreen | 38 | 12 | 18 | 10.1 | 38 | 12 |
| DOM API | ||||||
| The Document method exitFullscreen() requests that the element on this document which is currently being presented in fullscreen mode be taken out of fullscreen mode, restoring the previous state of the screen. This usually reverses the effects of a previous call to Element.requestFullscreen(). | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
exitFullscreen (returns promise) Returns a `Promise` | 69 | 79 | 64 | 16.4 | 69 | 16.4 |
| The fullscreenchange event is fired immediately after the browser switches into or out of fullscreen mode. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The Document.fullscreenElement read-only property returns the that is currently being presented in fullscreen mode in this document, or null if fullscreen mode is not currently in use. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The read-only fullscreenEnabled property on the Document interface indicates whether or not fullscreen mode is available. | 71 | 12 | 64 | 16.4 | 71 | 16.4 |
| The fullscreenerror event is fired when the browser cannot switch to fullscreen mode. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The fullscreenchange event is fired immediately after an Element switches into or out of fullscreen mode. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The fullscreenerror event is fired when the browser cannot switch to fullscreen mode. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The Element.requestFullscreen() method issues an asynchronous request to make the element be displayed in fullscreen mode. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
requestFullscreen (options navigationUI parameter) `options.navigationUI` parameter | 71 | 79 | | 16.4 | 71 | |
requestFullscreen (returns promise) Returns a `Promise` | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| The allowFullscreen property of the HTMLIFrameElement interface is a boolean value that reflects the allowfullscreen attribute of the iframe element, indicating whether to allow the iframe's contents to use Element.requestFullscreen. | 38 | 12 | 22 | 10.1 | 38 | 12 |
| The fullscreenElement read-only property of the ShadowRoot interface returns the element within the shadow tree that is currently displayed in full screen. | 71 | 79 | 64 | 16.4 | 71 | 16.4 |
| CSS selector | ||||||
fullscreen Fullscreen support | 69 | 12 | 47 | 16.4 | 69 | 16.4 |
all elements Select all elements in the fullscreen stack | | 12 | 43 | | | |
| Other | ||||||
fullscreen Experimental The HTTP Permissions-Policy header fullscreen directive controls whether the current document is allowed to use Element.requestFullscreen(). | 88 | 88 | | | 88 | |
- Previously available under a different name: :-webkit-full-screen (15)
- Previously available under a different name: :-moz-full-screen (9)
- Previously available under a different name: :-webkit-full-screen (6)
- Previously available under a different name: :-webkit-full-screen (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Previously available under a different name: :-webkit-full-screen (12)
- This feature was removed in a later browser version (38)
- Available with a vendor prefix: webkit (17)
- This feature was removed in a later browser version (18)
- Available with a vendor prefix: moz (9)
- Available with a vendor prefix: webkit (5.1)
- This feature was removed in a later browser version (38)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (15)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Previously available under a different name: mozCancelFullScreen (9)
- Available with a vendor prefix: webkit (5.1)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (15)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: moz (10)
- Available with a vendor prefix: webkit (5.1)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (20)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Previously available under a different name: mozFullScreenElement (9)
- Available with a vendor prefix: webkit (6)
- Available with a vendor prefix: webkit (25)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (20)
- Previously available under a different name: mozFullScreenEnabled (10)
- Available with a vendor prefix: webkit (6)
- Available with a vendor prefix: webkit (25)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (18)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: moz (10)
- Available with a vendor prefix: webkit (6)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (15)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: moz (10)
- Available with a vendor prefix: webkit (5.1)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (18)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: moz (10)
- Available with a vendor prefix: webkit (6)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Available with a vendor prefix: webkit (12)
- Available with a vendor prefix: webkit (15)
- This feature was removed in a later browser version (14)
- Available with a vendor prefix: webkit (12)
- Previously available under a different name: mozRequestFullScreen (9)
- Before Firefox 44, Firefox incorrectly allowed elements inside a `<frame>` or `<object>` element to request, and to be granted, fullscreen. In Firefox 44 and onwards this has been fixed: only elements in the top-level document or in an `<iframe>` element with the `allowfullscreen` attribute can be displayed fullscreen.
- Available with a vendor prefix: webkit (5.1)
- Available with a vendor prefix: webkit (18)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Only available on iPad, not on iPhone. Shows an overlay button which can not be disabled.
- Available with a vendor prefix: webkit (12)
- This feature was removed in a later browser version (18)
- Previously available under a different name: mozAllowFullScreen (9)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- Previously available under a different name: mozFullScreenElement (63)
- This browser only partially implements this feature
- Only available on iPad, not on iPhone.
- Shows an overlay button which can not be disabled. Swiping down exits fullscreen mode, making it unsuitable for some use cases like games.
- This feature was removed in a later browser version (79)
Syntax
document.onclick = (event) => {
if (document.fullscreenElement) {
document
.exitFullscreen()
.then(() => console.log("Document Exited from Full screen mode"))
.catch((err) => console.error(err));
} else {
document.documentElement.requestFullscreen();
}
}; Use cases
-
Using Fullscreen API
The Document method
Cautions
- Limited browser support. Check compatibility before use.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.