I have this web page that is already in fullscreen mode. Now, when testing with Google Chrome, if I make a call to the alert
function, the page would quit fullscreen mode.
While I understand that this might be standard behavior, I would still like to make the page re-enter fullscreen mode after quitting it. I now have this function:
function enterFullScreen() {
let element = document.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
}
else if (element["mozRequestFullScreen"]) {
element["mozRequestFullScreen"]();
}
else if (element["webkitRequestFullscreen"]) {
element["webkitRequestFullscreen"]();
}
else if (element["msRequestFullscreen"]) {
element["msRequestFullscreen"]();
}
}
It works fine when I run it directly in the console, but when I put it after the alert
call, believing it would make the page re-enter fullscreen mode, it ceases to work:
elem.onclick = function () {
alert("something");
enterFullScreen(); // Nothing happens what-so-ever. No errors either.
}
What might be the problem to this?