menu type Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:menu

Description

The type attribute specifies the type of menu.

Attribute Values

Value Description
listDefault. Specifies a list menu. A list of commands (li elements), that the user can perform or activate
context Specifies a context menu. The menu must be activated before the user can interact with the commands
toolbar Specifies a toolbar menu. Active commands, allows the user to interact with the commands immediately

The following code shows how to create a context menu:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div style="background:yellow;border:1px solid #cccccc;padding: 10px;" contextmenu="mymenu">
<p>Right-click inside this box to see the context menu!</p>

<menu type="context" id="mymenu">
  <menuitem label="Refresh" onclick="window.location.reload();" icon="https://www.java2s.com/style/demo/Opera.png"></menuitem>
  <menu label="Main Menu">
    <menuitem label="Sub 1" icon="https://www.java2s.com/style/demo/Firefox.png" onclick="window.open('http://java2s.com/' + window.location.href);"></menuitem>
    <menuitem label="Sub 2" icon="https://www.java2s.com/style/demo/Google-Chrome.png" onclick="window.open('http://java2s.com/' + window.location.href);"></menuitem>
  </menu><!--from w  ww . ja v a 2 s  .  c o m-->
  <menuitem label="Item" onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
</menu>

</div>

<p>works in Firefox!</p>

</body>
</html>

Related Tutorials