Skip to content

Instantly share code, notes, and snippets.

@dharFr dharFr/README.md
Last active Dec 11, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.