6
I have a website, and on the site the user when logging in will enter a page and this page should be full screen automatically without the user needing to click something.
I read that it is not possible for the browser to stay full screen without the permission of the user, so I thought to put an automatic click on the site as soon as the user enters, but still does not leave.
The code I have:
JS:
document.getElementById('teste').click();
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.msRequestFullscreen) {
document.documentElement.msRequestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
HTML:
<button id="teste" onClick="toggleFullScreen();"></button>
Is there any way I can do this?
To log in, the user probably has to click some button, right? You could take advantage of the very action of this button to activate the full screen.
– Renato Diniz
I already tested it and it won’t because it directs to another screen
– Maria
Good afternoon Maria, is there anything else that you think I should include in the answer? It became understandable to you?
– Guilherme Nascimento