HTML DOM fullscreenEnabled() Method
Example
Show a <video> element in fullscreen mode:
/* Get the element you want displayed in fullscreen */
var elem =
document.getElementById("myvideo");
/* Function to open fullscreen mode
*/
function openFullscreen() {
/* If fullscreen mode is
available, show the element in fullscreen */
if (document.fullscreenEnabled)
{
/* Show the element in fullscreen */
elem.requestFullscreen();
}
}
Try it Yourself »
Definition and Usage
The fullscreenEnabled() method returns a Boolean value indicating whether the document can be viewed in fullscreen mode.
The fullscreenEnabled() method returns true if fullscreen mode is available, otherwise false. Note: This method 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 method. Note: Each browser requires a specific prefix (see parentheses):
Method | |||||
---|---|---|---|---|---|
fullscreenEnabled() | 45.0 (webkit) | 11.0 (ms) | 47.0 (moz) | 5.1 (webkit) | 15.0 (webkit) |
Example
Using prefixes for cross-browser code:
/* If fullscreen mode is available, then do something */
if (
document.fullscreenEnabled || /* Standard syntax */
document.webkitFullscreenEnabled || /* Chrome, Safari and Opera syntax */
document.mozFullScreenEnabled ||/* Firefox syntax */
document.msFullscreenEnabled/* IE/Edge syntax */
) {
...
}
Try it Yourself »
Syntax
document.fullscreenEnabled()
Parameters
None |
Technical Details
Return Value: | A Boolean value, indicating whether the document can be viewed in fullscreen mode:
|
---|
❮ Document Object