HTML | DOM requestFullscreen() Method

The requestFullscreen() method opens the element in a full-screen mode. If the element is in full-screen mode, then nothing gets changed. The reverse of this method is exitFullscreen() method.

Syntax:

HTMLElementObject.exitFullscreen()

Parameters: It does not accept any parameters.

Return Value: It does not return any value.

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        HTML DOM requestFullscreen() Method
    </title
      
    <script
        var elem = document.documentElement; 
  
        function closeFullS() { 
            if (document.exitFullscreen) 
                document.exitFullscreen(); 
        
  
        function openFullS() { 
            if (elem.requestFullscreen) 
                elem.requestFullscreen(); 
        
    </script
</head
  
<body style="text-align:center;"
  
    <h1 style="color:green">
        GeeksforGeeks
    </h1
      
    <h2>
        HTML DOM requestFullscreen() Method
    </h2>
      
    <button onclick="openFullS();"
        Open Fullscreen 
    </button
      
    <button onclick="closeFullS();"
        Close Fullscreen 
    </button
</body
  
</html>         

chevron_right


Output:

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

  • Chrome
  • Firefox
  • Internet Explorer
  • Opera
  • Safari

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.