I am trying to figure out how to make a webpage instantly enter full screen the second it is opened.
I've got this:
var elem = document.documentElement;
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
:-webkit-full-screen {
background-color: white;
}
:-ms-fullscreen {
background-color: white;
}
:fullscreen {
background-color: white;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<button>Random button</button>
</head>
<body>
</body>
</html>
And I want openFullscreen() to be called the second the page is opened. Any way to do that?