HTML and CSS Reference
In-Depth Information
The global
contextmenu
attribute is used to define an element's context menu, which is
generally the menu invoked upon a right-click. The attribute's value should hold a string
that references the
id
of a
<menu>
tag found in the DOM. For example,
<div contextmenu="simpleMenu">
Widget
</div>
would reference the previously defined
menu
via a right-click. If there is no element found
or no value, then the element has no special context menu and the user agent should show
its default menu. Internet Explorer and many other browsers support an
oncontextmenu
attribute that could be used to implement the idea of this emerging attribute.
Again, all of this is completely speculative and meant to illustrate the concept; so far, no
browser natively implements this functionality, though it wouldn't be a stretch to have
JavaScript emulate this.
command Element
The
menu
element may contain not just links but also other interactive items, including the
newly introduced
command
element. This empty element takes a
label
and may have
an icon decoration as well. The
command
element has a
type
attribute, which may be set
to
command
,
radio
, or
checkbox
, though when
radio
is employed there needs to be
a
radiogroup
indication. A simple example here with the repurposed
menu
element should
illustrate the possible use of this element:
<menu type="command" label="Main Menu">
<command type="command" label="Add" icon="add.png">
<command type="command" label="Edit" icon="edit.png">
<command type="command" label="Delete" icon="delete.png">
<hr>
<menu type="command" label="Skin" id="skinMenu">
<command type="radio" radiogroup="skin" label="Classic">
<command type="radio" radiogroup="skin" label="Modern" checked>
<command type="radio" radiogroup="skin" label="Neo">
</menu>
<hr>
<command type="checkbox" label="Secure Mode">
</menu>
Such a menu might look like the following:
But again, this is just illustrative and in this case, I am somewhat skeptical about the
command
element because it seems to share many of the aspects of traditional form field
controls, so why more elements are needed is unclear.