Open In App

HTML | DOM onshow Event

Last Updated : 20 Jul, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

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

Supported Tags

  • <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 
 

html
<!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>

Output: 
Before: 
 


After right-click: 
 


 


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

  • Firefox


 


Next Article
Article Tags :

Similar Reads