Going fullscreen is one of the basic abilities of any application. It is useful if you are showing a video, slideshow or playing a first person shooter. Now we can get users to press buttons to enable and exit fullscreen. However, due to privacy reasons, the user has to do an action to enable fullscreen (so use the element.addEventListener function).
To use the Fullscreen API:
document.getElementById("something").addEventListener("click", function() {
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) {
if(document.documentElement.requestFullscreen) {document.documentElement.requestFullscreen();}
else if(document.documentElement.mozRequestFullScreen) {document.documentElement.mozRequestFullScreen();}
else if(document.documentElement.webkitRequestFullscreen) {document.documentElement.webkitRequestFullscreen();}
else if(document.documentElement.msRequestFullscreen) {document.documentElement.msRequestFullscreen();}
} else {
if(document.exitFullscreen) {document.exitFullscreen();}
else if(document.mozCancelFullScreen) {document.mozCancelFullScreen();}
else if(document.webkitExitFullscreen) {document.webkitExitFullscreen();}
}
});