Alert some text if an element can not be viewed in fullscreen mode:
document.addEventListener("fullscreenerror", function() {
alert("Fullscreen denied")
});
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.
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) |
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() {
...
});
In HTML:
<
element onfullscreenerror="
myScript">
In JavaScript:
object.onfullscreenerror = function(){
myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("fullscreenerror",
myScript);
Bubbles: | Yes |
---|---|
Cancelable: | No |
Event type: | Event |
HTML tags: | ALL HTML elements |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!