Skip to content

Instantly share code, notes, and snippets.

@dharFr
Last active December 11, 2015 18:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dharFr/4644490 to your computer and use it in GitHub Desktop.
Save dharFr/4644490 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.
  • Press Ctrl+Enter to toogle fullscreen mode

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.github.com/raw/4644490/685117b9074e23bfd0ed465e062d1a69db3a76c7/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();
}
}
}
document.addEventListener("keydown", function(e) {
if (e.keyCode == 13 && e.ctrlKey) {
toggleFullScreen();
}
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment