I made a button to allow the screen to go to full screen and vice versa. However, there is also shortcut for user to go to full screen using the computer/laptop button F11.
<html>
<head>
<title>
Zoom
</title>
</head>
<body>
<script type="text/javascript">
//fullscreen();
function fullscreen() {
var change = document.getElementById("fullscreen");
if ((document.fullScreenElement && document.fullScreenElement !== null) ||
(!document.mozFullScreen && !document.webkitIsFullScreen)) {
if (document.documentElement.requestFullScreen) {
document.documentElement.requestFullScreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullScreen) {
document.documentElement.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
}
change.innerHTML = "click to go Normal Screen";
}
else
{
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
change.innerHTML = "click to go Full Screen";
}
}
</script>
<button id="fullscreen" onclick="fullscreen()">Click to go Full Screen</button>
<h1>hi can u see me</h1>
<h2>hahahahah</h2>
<h3>blablablabla</h3>
<h4>heheheheh</h4>
</body>
</html>
Based on my code, by default, the screen is not in the full screen mode. If the user click the button, it will go to full screen mode and also the button label will change to view normal screen. But if the user click F11, it will go to fullscreen mode and I want the button to change to view normal mode. Please help me. thank you