Created
February 16, 2012 13:35
-
-
Save paulrouget/1844865 to your computer and use it in GitHub Desktop.
Fullscreen in a the context menu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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."