It is possible to enable full screen via Javascript at certain browsers. Even, you can place a single element in fullscreen (like a video), or the entire document.
Example for the whole document (extracted from MDN):
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();
}
}
}
This API is not yet fully standardized. A while ago, there was a restriction that full-screen mode would need to be triggered by user intervention (like a click on something). I’m not sure if the restriction still exists, I saw no reference in the current article of MDN (but there is clues that this limitation already existed in Firefox).
urls are all broken from the example
– Dorathoto
Example links no longer work.
– Bsalvo
@Bsalvo Thanks, I will see and put again online.
– Zuul
Who gave a negative vote! You can explain what is wrong in the answer ?
– Zuul