Open In App

HTML | DOM requestFullscreen() Method

Last Updated : 30 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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: html
<!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>         
Output: Supported Browsers: The browser supported by requestFullscreen() Method are listed below:
  • Chrome
  • Firefox
  • Internet Explorer
  • Opera
  • Safari

Article Tags :

Similar Reads