I am working on quiz and want to convert the screen into fullscreen mode on load of page for specific time, is there any way to achieve this or any alternative?
User interaction is required to enter full-screen mode. This is a security feature.
Imagine being able to force a popup window of some kind to go full screen, lock the mouse pointer, and play an ad without permission. Having an "Enable Full Screen" link or button whose visibility is toggled in the "Change Full Screen" event handler in the the documentation seems like a pragmatic/better approach.
Even if you'll try, you will get the following error message
Failed to execute 'requestFullScreen' on 'Element': API can only be initiated by a user gesture.
So, It's not possible to load a page on fullscreen mode but you can use the following code to trigger it on some action:
<script>
/* Get the documentElement (<html>) to display the page in fullscreen */
var elem = document.documentElement;
/* View in fullscreen */
function openFullscreen() {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.webkitRequestFullscreen) { /* Safari */
elem.webkitRequestFullscreen();
} else if (elem.msRequestFullscreen) { /* IE11 */
elem.msRequestFullscreen();
}
}
/* Close fullscreen */
function closeFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) { /* Safari */
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) { /* IE11 */
document.msExitFullscreen();
}
}
</script>
Reference: w3Schools - Full Screen