-
-
Save mika76/4026401f3f1ea2e50372d95814199141 to your computer and use it in GitHub Desktop.
Javascript: Toggle browser fullscreen mode
This file contains hidden or 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