You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
697 B
JavaScript
31 lines
697 B
JavaScript
2 years ago
|
function toggleFullScreen() {
|
||
|
const doc = window.document;
|
||
|
const docEl = doc.documentElement;
|
||
|
|
||
|
var requestFullScreen =
|
||
|
docEl.requestFullscreen ||
|
||
|
docEl.mozRequestFullScreen ||
|
||
|
docEl.webkitRequestFullScreen ||
|
||
|
docEl.msRequestFullscreen;
|
||
|
var cancelFullScreen =
|
||
|
doc.exitFullscreen ||
|
||
|
doc.mozCancelFullScreen ||
|
||
|
doc.webkitExitFullscreen ||
|
||
|
doc.msExitFullscreen;
|
||
|
|
||
|
if (
|
||
|
!doc.fullscreenElement &&
|
||
|
!doc.mozFullScreenElement &&
|
||
|
!doc.webkitFullscreenElement &&
|
||
|
!doc.msFullscreenElement
|
||
|
) {
|
||
|
requestFullScreen.call(docEl);
|
||
|
} else {
|
||
|
cancelFullScreen.call(doc);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
document.addEventListener("dblclick", () => {
|
||
|
toggleFullScreen();
|
||
|
});
|