Home > Article > Web Front-end > HTML5 specifies the context menu attribute of the element contextmenu
Example
Specifies the context menu of the dc6dce4a544fdca2df29d5ac0ea9906b element. The context menu will appear 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>
Browser support
Firefox
Currently only Firefox supports the contextmenu attribute.
Definition and Usage
The contextmenu attribute specifies the context menu of the element. When the user right-clicks on an element, a context menu appears.
The value of the contextmenu attribute is the id of the 5c0e96d12fc7501cef2ae2efde646ee0 element to be opened.
Differences between HTML 4.01 and HTML5
The contextmenu attribute is new in HTML5.
Syntax
<element contextmenu="menu_id">
Attribute value
Value | Description |
menu_id | The id of the 5c0e96d12fc7501cef2ae2efde646ee0 element to be opened. |
The contexmenu attribute is used to define the context menu of the dc6dce4a544fdca2df29d5ac0ea9906b element. The so-called context menu appears when you right-click the element with a book.
Sample code:
<!doctype html> <html> <head> <meta charset="utf-8"> <title> </title> </head> <body> <div contextmenu="mymenu">上下文菜单 <menu type="context" id="mymenu"> <menuitem label="微信分享"></menuitem> <menuitem label="微博分享"></menuitem> </menu> </div> </body> </html>
Note: Only supported by Firefox, QQ, IE, and Google. . .
The above is the detailed content of HTML5 specifies the context menu attribute of the element contextmenu. For more information, please follow other related articles on the PHP Chinese website!