Home  >  Article  >  Web Front-end  >  HTML5 specifies the context menu attribute of the element contextmenu

HTML5 specifies the context menu attribute of the element contextmenu

黄舟
黄舟Original
2017-11-03 10:11:022579browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn