HTML DOM fullscreenElement Property
Example
Get the element that is currently in fullscreen mode:
var elem = document.fullscreenElement;
Definition and Usage
The fullscreenElement property returns the current element that is displayed in fullscreen mode, or null when not in fullscreen.
Note: This property requires specific prefixes to work in different browsers (see Browser Support below).
Tip: Use the element.requestFullscreen() method to view an element in fullscreen mode.
Tip: Use the element.exitFullscreen() method to cancel fullscreen mode.
Browser Support
The numbers in the table specify the first browser version that fully supports the property. Note: Each browser requires a specific prefix (see parentheses):
Property | |||||
---|---|---|---|---|---|
fullscreenElement | 45.0 (webkit) | 11.0 (ms) | 47.0 (moz) | 5.1 (webkit) | 15.0 (webkit) |
Example
Using prefixes for cross-browser code:
if (
document.fullscreenElement || /* Standard syntax */
document.webkitFullscreenElement || /* Chrome, Safari and Opera syntax */
document.mozFullScreenElement ||/* Firefox syntax */
document.msFullscreenElement /* IE/Edge syntax */
) {
...
}
Syntax
document.fullscreenElement
Technical Details
Return Value: | Returns the element that is currently in fullscreen mode, or null if fullscreen mode is not available |
---|
❮ Document Object