A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/html/html-dom-menu-object/ below:

HTML | DOM Menu Object

HTML | DOM Menu Object

Last Updated : 09 Feb, 2022

The DOM Menu Object is used to

represent an HTML <menu> element

. This tag defines a list of commands. It is used for context menus, toolbars and for listing form controls and commands.

Syntax: Properties: Examples-1:

Accessing Menu Object.

html
<!DOCTYPE html>
<html>

<body>

    <div style="background:green;
                padding: 10px;"
         contextmenu="MENU">
        <p>Right-click inside the box 
          to see the context menu!!!</p>

        <menu type="context" 
              id="MENU">
            <menuitem label="Refresh" 
                      onclick="window.location.reload();"
                      icon="ico_reload.png">
          </menuitem>

            <menuitem label="Email This Page" 
                      onclick="window.location=
                         'mailto:?body='
                               +window.location.href;">
          </menuitem>
        </menu>

    </div>
    <script>
        function Geeks() {
            var y = document.getElementById("MENU");

        }
    </script>

    <p>This example can work only on Firefox!</p>

</body>

</html>
Output: Example-2:

Creating Menu Object.

html
<!DOCTYPE html>
<html>

<body>

    <div style="background:pink;
                padding: 10px;"
         contextmenu="MENU">
        <p>Right-click inside the box 
          to see the context menu!!!</p>

        <menu type="context"
              id="MENU">
            <menuitem label="Refresh"
                      onclick="window.location.reload();"
                      icon="ico_reload.png">
          </menuitem>

            <menuitem label="Email This Page"
                      onclick="window.location=
                               'mailto:?body='
                               +window.location.href;">
          </menuitem>
        </menu>

    </div>
    <script>
        function Geeks() {
          
           //creating menu
            var y = 
                document.createElement("MENU"); 

            document.getElementById("MENU");
        }
    </script>

    <p>This example can work only on Firefox!</p>

</body>

</html>
Output: Note:

The

element is currently NOT supported in any of the major browsers. Browsers Supported:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4