34 lines
946 B
JavaScript
34 lines
946 B
JavaScript
|
|
function isFullScreen() {
|
|
return (document.fullScreenElement && document.fullScreenElement !== null) || document.mozFullScreen || document.webkitIsFullScreen;
|
|
}
|
|
|
|
function requestFullScreen(element) {
|
|
if (element.requestFullscreen)
|
|
element.requestFullscreen();
|
|
else if (element.msRequestFullscreen)
|
|
element.msRequestFullscreen();
|
|
else if (element.mozRequestFullScreen)
|
|
element.mozRequestFullScreen();
|
|
else if (element.webkitRequestFullscreen)
|
|
element.webkitRequestFullscreen();
|
|
}
|
|
|
|
function exitFullScreen() {
|
|
if (document.exitFullscreen)
|
|
document.exitFullscreen();
|
|
else if (document.msExitFullscreen)
|
|
document.msExitFullscreen();
|
|
else if (document.mozCancelFullScreen)
|
|
document.mozCancelFullScreen();
|
|
else if (document.webkitExitFullscreen)
|
|
document.webkitExitFullscreen();
|
|
}
|
|
|
|
function toggleFullScreen(element) {
|
|
if (isFullScreen())
|
|
exitFullScreen();
|
|
else
|
|
requestFullScreen(element || document.documentElement);
|
|
}
|