Closed Infocatcher closed 10 years ago
Testcase: http://jsfiddle.net/9JgGa/1/ => http://fiddle.jshell.net/9JgGa/1/show/ or http://fiddle.jshell.net/9JgGa/1/show/light/
<!DOCTYPE HTML>
<meta charset="utf-8"/>
<title>FullScreen test</title>
<script type="text/javascript">
function toggleFullScreen() {
if(
document.fullscreenElement
|| document.mozFullScreenElement
|| document.msFullScreenElement
|| document.webkitFullScreenElement
) {
document.exitFullscreen && document.exitFullscreen()
|| document.mozCancelFullScreen && document.mozCancelFullScreen()
|| document.msExitFullscreen && document.msExitFullscreen()
|| document.webkitExitFullscreen && document.webkitExitFullscreen();
}
else {
var root = document.documentElement;
root.requestFullscreen && root.requestFullscreen()
|| root.mozRequestFullScreen && root.mozRequestFullScreen()
|| root.msRequestFullScreen && root.msRequestFullScreen()
|| root.webkitRequestFullScreen && root.webkitRequestFullScreen();
}
}
</script>
<body>
<button onclick="toggleFullScreen()">Toggle FullScreen</button>
</body>
We can use document.mozFullScreen to detect this. https://developer.mozilla.org/en-US/docs/Web/API/document.mozFullScreen