HTML contextmenuAttribute

HTML 全局属性HTML Global Attributes

Examples

Specifies the context menu of a <div> element. The context menu will be displayed when the user right-clicks on the element:

<div contextmenu="mymenu">

<menu type="context" id="mymenu">
  <menuitem label="Refresh"></menuitem>
  <menuitem label="Twitter"></menuitem>
</menu>

</div>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Currently, only Firefox browser supports the contextmenu attribute.


Definition and Usage

The contextmenu attribute specifies the context menu of an element. The context menu will be displayed when the user right-clicks on the element./p>

The value of the contextmenu attribute is the id of the <menu> element to be opened.


Differences between HTML 4.01 and HTML5

The contextmenu attribute is a new attribute in HTML5.


Syntax

<element contextmenu="menu_id">

Attribute Values

Value Description
menu_id The id of the <menu> element to be opened.


HTML 全局属性HTML Global Attributes Other Extensions