HTML | DOM onshow Event

The onshow event occurs when a user right click on en element and <menu> element is shown as a context menu.

Syntax:

  • In HTML:
    <element onshow="Script">
  • In JavaScript:
    object.onshow = function(){Script};
  • In JavaScript, using the addEventListener() method:
    object.addEventListener("show", Script);

Example: Using the addEventListener() method



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
      HTML DOM onshow event
  </title>
</head>
  
<head>
    <style>
  
    </style>
</head>
  
<body>
  
    <center>
        <h1 style="color:green">
          GeekforGeeks
      </h1>
        <h1 contextmenu="Mmenu">
          HTML DOM onshow event
      </h1>
  
        <menu type="context" 
              id="Mmenu"></menu>
    </center>
    <script>
        document.getElementById(
          "Mmenu").addEventListener("show", GFGfun);
  
        function GFGfun() {
            alert("Context menu");
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before:

After right-click:

Supported Browsers: The browsers supported by HTML DOM onshow Event are listed below:

  • Firefox



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.