Created
February 25, 2019 15:24
-
-
Save ruempel/2790a623b8bc0d1a69a5556a01211cbd to your computer and use it in GitHub Desktop.
Demonstrate JavaScript fullscreen API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Fullscreen Demo</title> | |
<style> | |
html { | |
font-size: 20px; | |
} | |
section { | |
background-color: #bda; | |
padding: 3rem; | |
margin: 1rem; | |
} | |
</style> | |
<script> | |
function activateFullscreen() { | |
let elem = document.getElementById("second"); | |
if (elem.requestFullscreen) { | |
elem.requestFullscreen(); | |
} | |
} | |
window.onload = function () { | |
document.getElementById("switch").addEventListener("click", activateFullscreen); | |
}; | |
</script> | |
</head> | |
<body> | |
<section>First Section</section> | |
<section id="second"> | |
<p>Second Section</p> | |
<button id="switch">Activate Fullscreen (Come back with ESCAPE key)</button> | |
</section> | |
<section>Third Section</section> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment