Last active
August 29, 2015 14:17
-
-
Save aindong/5c0ffae786b20abd4ec6 to your computer and use it in GitHub Desktop.
Toggle Fullscreen mode on a webpage
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
function toggleFullScreen() { | |
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); | |
} | |
} else { | |
if (document.cancelFullScreen) { | |
document.cancelFullScreen(); | |
} else if (document.mozCancelFullScreen) { | |
document.mozCancelFullScreen(); | |
} else if (document.webkitCancelFullScreen) { | |
document.webkitCancelFullScreen(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment