fullscreenerror Event
Example
Alert some text if an element can not be viewed in fullscreen mode:
document.addEventListener("fullscreenerror", function() {
alert("Fullscreen denied")
});
Definition and Usage
The fullscreenerror event occurs when an element can not be viewed in fullscreen mode, even if it has been requested.
Note: This event 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 event. Note: Each browser requires a specific prefix (see parentheses):
Event | |||||
---|---|---|---|---|---|
fullscreenerror | 45.0 (webkit) | 11.0 (ms) | 47.0 (moz) | 5.1 (webkit) | 15.0 (webkit) |
Example
Using prefixes for cross-browser code:
/* Standard syntax */
document.addEventListener("fullscreenerror",
function() {
...
});
/* Firefox */
document.addEventListener("mozfullscreenerror", function() {
...
});
/* Chrome, Safari and Opera */
document.addEventListener("webkitfullscreenerror",
function() {
...
});
/* IE / Edge */
document.addEventListener("msfullscreenerror", function() {
...
});
Syntax
In HTML:
<element onfullscreenerror="myScript">
In JavaScript:
object.onfullscreenerror = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("fullscreenerror", myScript);
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Technical Details
Bubbles: | Yes |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | ALL HTML elements |