Can someone explain what the contextmenu attribute does in HTML5?

can someone explain what the contextmenu attribute does and can it be used with all HTML elements and can someone point me to some demos / examples?

+6
html5
source share
6 answers

The contextmenu attribute refers to the <menu> element that the user agent should display when the user requests the context menu (for example, using the right mouse button or the Menu / Hyper key on modern keyboards.

You can find an example here.

+3
source share

You can see how this might look in this demo: https://bug617528.bugzilla.mozilla.org/attachment.cgi?id=554309

At the time of writing, only FireFox 8 supports it.

+3
source share

A context menu appears when the user right-clicks on an interface element. The contextmenu attribute is the identifier of the <menu> element that opens when the user right-clicks on an element with this attribute.

+2
source share

Quote: easy for you to understand:

The contextmenu attribute allows you to display a menu without the need for valuable user interface space for the menu. this is a menu that triggers events, such as a mouse or keyboard, providing a menu bubble that provides options and actions based on these choices.

Source: http://net.tutsplus.com/tutorials/html-css-techniques/html5-globals-and-you/

See the official link for more information:

http://www.w3.org/TR/html5/interactive-elements.html

+1
source share

A context menu should be used in the input field to indicate which menu item for this field. The menus look like a right-click menu or a drop-down list, however they are not implemented in any browser, but you should avoid using them.

This may help clarify the situation: http://dev.w3.org/html5/spec-author-view/interactive-elements.html

0
source share
 <form name="npc"> <label>Character name: <input name="char" type="text" contextmenu="namemenu" required></label> <menu type="context" id="namemenu"> <command label="Pick random name" onclick="document.forms.npc.elements.char.value = getRandomName()"> <command label="Prefill other fields based on name" onclick="prefillFields(document.forms.npc.elements.char.value)"> </menu> </form> 

http://www.w3.org/TR/html5/interactive-elements.html#context-menus

-one
source share

All Articles