Forked from robnyman/Fullscreen API, fullscreenchange.js
Last active
April 4, 2016 16:29
-
-
Save arturparkhisenko/53e7395f4ba21a617d26 to your computer and use it in GitHub Desktop.
Fullscreen API, fullscreenchange
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
var inFullScreen = document.fullscreenEnabled || document.fullscreenElement || | |
window.fullScreen || document.webkitIsFullScreen || document.msFullscreenEnabled; | |
if (inFullScreen) { | |
//do something.. | |
if (document.exitFullscreen) { | |
document.exitFullscreen(); | |
} else if (document.mozCancelFullScreen) { | |
document.mozCancelFullScreen(); | |
} else if (document.webkitExitFullscreen) { | |
document.webkitExitFullscreen(); | |
} else if (document.msExitFullscreen) { | |
document.msExitFullscreen(); | |
} | |
} else { | |
//do something.. | |
var docElement = document.documentElement; | |
if (docElement.requestFullscreen) { | |
docElement.requestFullscreen(); | |
} else if (docElement.mozRequestFullScreen) { | |
docElement.mozRequestFullScreen(); | |
} else if (docElement.webkitRequestFullscreen) { | |
docElement.webkitRequestFullscreen(); | |
} else if (docElement.msRequestFullscreen) { | |
docElement.msRequestFullscreen(); | |
} | |
} | |
// other | |
document.addEventListener("fullscreenchange", function () { | |
fullscreenState.innerHTML = (document.fullscreen)? "" : "not "; | |
}, false); | |
document.addEventListener("mozfullscreenchange", function () { | |
fullscreenState.innerHTML = (document.mozFullScreen)? "" : "not "; | |
}, false); | |
document.addEventListener("webkitfullscreenchange", function () { | |
fullscreenState.innerHTML = (document.webkitIsFullScreen)? "" : "not "; | |
}, false); | |
document.addEventListener("msfullscreenchange", function () { | |
fullscreenState.innerHTML = (document.msFullscreenElement)? "" : "not "; | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment