Skip to content

Instantly share code, notes, and snippets.

@jebaird
Forked from dharFr/README.md
Last active December 8, 2015 15:41
Show Gist options
  • Save jebaird/2f79feec2703949b2564 to your computer and use it in GitHub Desktop.
Save jebaird/2f79feec2703949b2564 to your computer and use it in GitHub Desktop.
Web is more beautiful in Full Screen : A simple bookmarklet to toogle fullScreenMode in modern browsers.

Web is more beautiful in Full Screen

Toogle Fullscreen Bookmarklet

A simple bookmarklet to enable fullScreenMode in modern browsers.

Usage

  • Copy loader.js code into a bookmark's location field.

Credits

javascript:(function () {
var bodyNode = document.body,
scriptNode = bodyNode.appendChild(document.createElement('script'));
scriptNode.onload = function () { bodyNode.removeChild(scriptNode); bodyNode = scriptNode = null; };
scriptNode.src = 'https://gist.githubusercontent.com/jebaird/2f79feec2703949b2564/raw/35be65ce3fabf459bed8c939a7a393249a8bdccd/toogleFullScreenMode.js';
})();
;(function(){
function toggleFullScreen() {
if (!document.fullscreenElement && // alternative standard method
!document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
toggleFullScreen();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment