HTML | DOM fullscreenerror Event

The HTML DOM fullscreenerror event occurs when an element can not be viewed in fullscreen mode, even if it has been requested.
Use the element.requestFullscreen() method to view an element in fullscreen mode and the element.exitFullscreen() method to cancel fullscreen mode.

Syntax:

  • In HTML:
    <element onfullscreenerror="myScript">
  • In JavaScript:
    object.onfullscreenerror = function(){myScript};
  • In JavaScript, using the addEventListener() method:
    object.addEventListener("fullscreenerror", myScript);

Using prefixes for cross-browser code:

  • Standard syntax:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

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

    chevron_right

    
    

  • Firefox:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    document.addEventListener("mozfullscreenerror", function() {
      ...
    });

    chevron_right

    
    

  • Chrome, Safari and Opera:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    document.addEventListener("webkitfullscreenerror", function() {
      ...
    });

    chevron_right

    
    

  • Edge:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    document.addEventListener("msfullscreenerror", function() {
      ...
    }); 

    chevron_right

    
    

Example: Display an alert message if an element can not be viewed in fullscreen mode:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Supported Browsers: The browsers supported by HTML DOM fullscreenerror Event are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Apple Safari
  • Opera

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.