Skip to content

Instantly share code, notes, and snippets.

@potch
Created August 14, 2013 18:37
Show Gist options
  • Save potch/6234085 to your computer and use it in GitHub Desktop.
Save potch/6234085 to your computer and use it in GitHub Desktop.
JavaScript to add "Fullscreen" context menu item.
function addFullScreenMenu () {
var menu = document.createElement('menu');
var item = document.createElement('menuitem');
menu.setAttribute('id', 'fsmenu');
menu.setAttribute('type', 'context');
item.setAttribute('label', 'Fullscreen');
item.addEventListener('click', function (e) {
if (window.fullScreen) {
document.body.mozCancelFullScreen();
} else {
document.body.mozRequestFullScreen();
}
});
menu.appendChild(item);
document.body.appendChild(menu);
document.body.setAttribute('contextmenu', 'fsmenu');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment