Home > Web Front-end > H5 Tutorial > body text

HTML5 specifies the context menu attribute of the element contextmenu

黄舟
Release: 2017-11-03 10:11:02
Original
2578 people have browsed it

Example

Specifies the context menu of the

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>
Copy after login

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

element to be opened.

Differences between HTML 4.01 and HTML5

The contextmenu attribute is new in HTML5.

Syntax

<element contextmenu="menu_id">
Copy after login

Attribute value

ValueDescription
menu_idThe id of the element to be opened.

The contexmenu attribute is used to define the context menu of the

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!