Fullscreen API fullscreenEnabled()
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.
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: Some browsers require a specific prefix (see parentheses):
Method | |||||
---|---|---|---|---|---|
fullscreenEnabled() | 71.0 45.0 (webkit) |
12.0 11.0 (ms) |
64.0 47.0 (moz) |
6.0 (webkit) | 58.0 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 || /* Safari */
document.msFullscreenEnabled/* IE11 */
) {
...
}
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:
|
---|