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:
html
Output:
Supported Browsers: The browser supported by requestFullscreen() Method are listed below:
HTMLElementObject.exitFullscreen()Parameters: It does not accept any parameters. Return Value: It does not return any value. Example:
<!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>
Supported Browsers: The browser supported by requestFullscreen() Method are listed below:
- Chrome
- Firefox
- Internet Explorer
- Opera
- Safari