HTML | DOM exitFullscreen() Method

The exitFullscreen() method requests the element which is currently in a full-screen mode to be taken out of full-screen mode. If element is not in full-screen mode, then nothing gets changed. The reverse of this method is requestFullscreen().

Syntax:

HTMLElementObject.exitFullscreen()

Parameters: No parameters required.

Return Value: No return value.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      HTML | DOM exitFullscreen() Method
    </title>
  
    <!--script for close and open fullscreen-->
    <script>
        var elem = document.documentElement;
  
        function closeFullscreen() {
            if (document.exitFullscreen)
                document.exitFullscreen();
        }
  
        function openFullscreen() {
            if (elem.requestFullscreen)
                elem.requestFullscreen();
        }
    </script>
</head>
  
<body>
  
    <h2>Welcome to GeeksforGeeks</h2>
    <p>
      Click on the "Open Fullscreen" button to open this page in" 
      + "fullscreen mode. Close it by either clicking the "Esc" key"
      +" on your keyboard, or with the "Close Fullscreen" button.
    </p>
  
    <button onclick="openFullscreen();">
      Open Fullscreen
    </button>
    <button onclick="closeFullscreen();">
      Close Fullscreen
    </button>
  
</body>
  
</html>

chevron_right


Output:
Open Fullscreen

Exit Fullscreen

Supported Browsers: The browser supported by DOM exitFullscreen() Method are listed below:

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


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.