Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

What is oncontextmenu Event in JavaScript



On right click of an element, when the context menu opens, then it is known as oncontextmenu in JavaScript.

Example

You can try to run the following code to learn how to work with oncontextmenu event in JavaScript −

<html>
   <head>
      <script>
         <!--
             function sayHello() {
                alert("You right clicked here.")
             }
          //-->
      </script>
   </head>
   <body>
      <p oncontextmenu = "sayHello()">Right click</p>
   </body>
</html>
Updated on: 2020-06-19T11:03:46+05:30

400 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements