Skip to content

Instantly share code, notes, and snippets.

@michaelwhyte
Last active August 29, 2015 14:06
Show Gist options
  • Save michaelwhyte/026821f24072edddd83c to your computer and use it in GitHub Desktop.
Save michaelwhyte/026821f24072edddd83c to your computer and use it in GitHub Desktop.
Code for exiting fullscreen mode using the HTML5 fullscreen API
var btn02 = document.getElementById('btn-02');
// Exit full-screen mode when btn02
// is clicked
btn02.addEventListener('click', function(){
exitFullscreen();
}, false);
// Helper function for dealing
// with the various ways that
// different browsers handle
// exiting full-screen mode
function exitFullscreen() {
if(document.exitFullscreen) {
document.exitFullscreen();
} else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if(document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment