HTML | DOM fullscreenEnabled() Method

The fullscreenEnabled() method in HTML DOM is used to check the document can be viewed in full screen mode or not. It returns a single read-only Boolean value. This method may require specific prefixes to work with different browsers.

Syntax:

document.fullscreenEnabled()

Parameters: This method does not accept any parameters.



Return Value: It returns boolean value:

  • True: If the document can be viewed in full screen mode.
  • False: If the document cannot be viewed in full screen mode.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM fullscreenEnabled() method
        </title>
          
        <!-- script to check full screen enabled or not -->
        <script>
            function requestFullScreen() {
                let isFullscreenSupported =
                  
                    /* Standard syntax */
                    (document.fullscreenEnabled || 
                      
                    /* Chrome, Safari and Opera */
                    document.webkitFullscreenEnabled ||
                      
                     /* Firefox */
                    document.mozFullScreenEnabled ||
                      
                    /* IE/Edge */
                    document.msFullscreenEnabled);
      
                document.querySelector('.isSupported').innerHTML 
                        = isFullscreenSupported;
            }
        </script>
    </head>
      
    <body>
        <h1>
            GeeksforGeeks
        </h1>
          
        <h2>
            fullscreenEnabled() method
        </h2>
          
        <!-- script called here -->
        <button onclick="requestFullScreen();">
            Check fullscreen supported
        </button>
          
        <p>Fullscreen support:</p>
          
        <div class="isSupported"></div>
          
    </body>
</html>                                

chevron_right


Output:
Before Click on the button:
check_fullscreen
After click on the button:
check_fullscreen_output

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <title>
            HTML DOM fullscreenEnabled() method
        </title>
          
        <!-- script to enable full screen -->
        <script>
            function goFullScreen() {
                if (
                      
                    /* Standard syntax */
                    document.fullscreenEnabled || 
                      
                    /* Chrome, Safari and Opera */
                    document.webkitFullscreenEnabled || 
                      
                    /* Firefox */
                    document.mozFullScreenEnabled ||
                      
                    /* IE/Edge */
                    document.msFullscreenEnabled 
                ) {
                    elem = document.querySelector('#image');
                    elem.requestFullscreen();
                }
                else {
                    console.log('Fullscreen not enabled')
                }
            }
        </script>
    </head>
      
    <body>
        <h1>GeeksforGeeks</h1>
          
        <h2>
            HTML DOM fullscreenEnabled() method
        </h2>
          
        <img id = "image" src =
        <br>
          
        <button onclick = "goFullScreen();">
            Fullscreen
        </button>
          
    </body>
</html>                    

chevron_right


Output:
Before Click on the button:
go-fullscreen
After click on the button:
go-fullscreen-output

Supported Browsers: The browser supported by fullscreenEnabled() method are listed below:

  • Google Chrome 45.0 -webkit-
  • Firefox 47.0 -moz-
  • Internet Explorer 11.0 -ms-
  • Apple Safari 5.1 -webkit-
  • Opera 15.0 -webkit-


My Personal Notes arrow_drop_up

Maybe this silence is dangerous

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.