Skip to content

Instantly share code, notes, and snippets.

@paulrouget
Created February 16, 2012 13:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulrouget/1844865 to your computer and use it in GitHub Desktop.
Save paulrouget/1844865 to your computer and use it in GitHub Desktop.
Fullscreen in a the context menu
<canvas contextmenu="fullscreenmenu"></canvas>
<!-- can be a div if you prefer -->
<menu id="fullscreenmenu" type="context">
<menuitem label="fullscreen"
onclick="document.querySelector('canvas').requestFullScreen()">
</menuitem>
</menu>
<script>
HTMLElement.prototype.requestFullScreen =
HTMLElement.prototype.requestFullScreen ||
HTMLElement.prototype.webkitRequestFullScreen ||
HTMLElement.prototype.mozRequestFullScreen ||
HTMLElement.prototype.oRequestFullScreen ||
HTMLElement.prototype.msRequestFullScreen;
</script>
@neave
Copy link

neave commented Feb 24, 2012

Thanks for this. However it looks like 'menuitem' has been deprecated in favour of 'command' instead: http://dev.w3.org/html5/spec-author-view/the-command-element.html

From http://caniuse.com/menu - "Partial support in Firefox refers to using the non-standard "menuitem" child elements, where the current spec uses "command" child elements. It is also currently limited to context menus, not toolbar menus."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment