Last active
August 30, 2019 09:30
-
-
Save georgebyte/3b915dd6b11a2660c096 to your computer and use it in GitHub Desktop.
Javascript: Toggle browser fullscreen mode
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
$('body').click(function(event) { | |
var el, rfs; | |
if ($('body').hasClass('fullscreen')) { | |
el = document; | |
rfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen; | |
$('body').removeClass('fullscreen'); | |
} else { | |
el = document.documentElement; | |
rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen; | |
$('body').addClass('fullscreen'); | |
} | |
if ('undefined' !== typeof rfs && rfs) { | |
var a = rfs.call(el); | |
} else if ('undefined' !== typeof window.ActiveXObject) { | |
var wscript = new ActiveXObject('WScript.Shell'); | |
if (null !== wscript) { | |
wscript.SendKeys('{F11}'); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment