I'm using the following code below to Toggle fullscreen mode in Chrome.
It works great unless I launch Chrome with the --start-fullscreen flag. From there, it looks like it's trying to do something; the indicator changes from "Press [Esc] to Exit Full Screen" to "Press [F11] To Exit Full Screen", but the window stays in fullscreen.
I would like the application to load in full screen (e.g. on system startup), but have the ability to exit/re-enter fullscreen with a toggle button.
Any ideas?
<html>
<head>
</head>
<body>
<input type="button" value="Toggle Fullscreen" onclick="ToggleFs()"></input>
<script type="text/javascript">
var ToggleFs = function() {
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement) {
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.webkitCancelFullscreen) {
document.webkitCancelFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
}
</script>
</body>
</html>