fullscreenerror Event

Definition and Usage

The 'fullscreenerror' event occurs when an element cannot be viewed in full-screen mode, even though it has been requested.

Note:This event requires specific prefixes to work in different browsers (see more examples below).

Note:Please use element.requestFullscreen() method to view the element in full-screen mode.

Note:Please use element.exitFullscreen() Method to cancel full-screen mode.

Example

If the element cannot be viewed in full-screen mode, prompt some text:

document.addEventListener("fullscreenerror", function() {
  alert("Fullscreen denied")
});

Try it yourself

Syntax

In HTML:

<element onfullscreenerror="myScript">

In JavaScript:

object.onfullscreenerror = function(){myScript});

In JavaScript, use the addEventListener() method:

object.addEventListener("fullscreenerror", myScript);

Note:Internet Explorer 8 and earlier versions do not support addEventListener() method.

Technical Details

Bubble: Supported
Cancelable: Not supported
Event type: Event
Supported HTML tags: All HTML elements

Browser Support

The numbers in the table indicate the first browser version that fully supports this event. Note: Each browser requires a specific prefix (see inside the parentheses):

Event Chrome IE Firefox Safari Opera
fullscreenerror 45.0 (webkit) 11.0 (ms) 47.0 (moz) 5.1 (webkit) 15.0 (webkit)

Example

Prefixes for cross-browser code usage:

/* 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() {
  ...
});