Skip to content

Instantly share code, notes, and snippets.

@szolotykh
Created January 7, 2015 20:57
Show Gist options
  • Save szolotykh/d38352274642f6555985 to your computer and use it in GitHub Desktop.
Save szolotykh/d38352274642f6555985 to your computer and use it in GitHub Desktop.
Web page (div) fullscreen mode
<html>
<head>
<script>
function goFullScreen(elem){
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
} else if (elem.mozRequestFullScreen) {
elem.mozRequestFullScreen();
} else if (elem.webkitRequestFullscreen) {
elem.webkitRequestFullscreen();
}
}
function init(){
console.log("init");
// goFullScreen not works here
}
</script>
</head>
<body onload="init();">
<div id = "container">
Full screen
</div>
<input type="button" value = "goFullScreen" onclick="goFullScreen(document.getElementById('container'));" />
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment