How do I make the browser go fullscreen using javascript?
press f11. idk if it's possible to do it using javascript.
edit: I just realized it is possible. I've seen it before.
Read this: Fullscreen API - Web APIs | MDN
I cant get it to work.
What did you try that didn't work?
I just cant figure it out. Snap will throw an error, or it will do absolutely nothing.
I got it to work with this script
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
and this is basically just a copy and paste of the example in the link snapenilk gave
and this
function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}
document.addEventListener("keypress", function(e) {
if (e.keyCode === 13) {
toggleFullScreen();
}
}, false);
is a copy and paste of the example, but you have to press enter to enter full screen.
Thanks!