Created
January 15, 2014 13:41
-
-
Save Dexterstat/8436393 to your computer and use it in GitHub Desktop.
full element on a webpage (escape full screen on changing link)
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
function cancelFullScreen(el) { | |
var requestMethod = el.cancelFullScreen||el.webkitCancelFullScreen||el.mozCancelFullScreen||el.exitFullscreen; | |
if (requestMethod) { // cancel full screen. | |
requestMethod.call(el); | |
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE. | |
var wscript = new ActiveXObject("WScript.Shell"); | |
if (wscript !== null) { | |
wscript.SendKeys("{F11}"); | |
} | |
} | |
} | |
function requestFullScreen(el) { | |
// Supports most browsers and their versions. | |
var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen; | |
if (requestMethod) { // Native full screen. | |
requestMethod.call(el); | |
} else if (typeof window.ActiveXObject !== "undefined") { // Older IE. | |
var wscript = new ActiveXObject("WScript.Shell"); | |
if (wscript !== null) { | |
wscript.SendKeys("{F11}"); | |
} | |
} | |
return false | |
} | |
function toggleFull() { | |
var elem = document.body; // Make the body go full screen. | |
var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || (document.mozFullScreen || document.webkitIsFullScreen); | |
if (isInFullScreen) { | |
cancelFullScreen(document); | |
} else { | |
requestFullScreen(elem); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment