Open In App

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.
 

Supported Tags



Syntax: 
 

<element onshow="Script">
object.onshow = function(){Script};
object.addEventListener("show", Script);

Example: Using the addEventListener() method 
 






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

 


Article Tags :