Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY CYBERSECURITY DATA SCIENCE
     ❯   

HTML oncontextmenu Attribute


Definition and Usage

The oncontextmenu attribute fires when the user right-clicks on an element to open the context menu.

Note: Although the oncontextmenu event is supported in all browsers, the contextmenu attribute is currently only supported in Firefox.


Applies to

The oncontextmenu attribute is part of the Event Attributes, and can be used on any HTML elements.

Elements Event
All HTML elements oncontextmenu

Example

Execute a JavaScript when a context menu is triggered:

<div oncontextmenu="myFunction()" contextmenu="mymenu">
Try it Yourself »

Browser Support

Event Attribute
oncontextmenu Yes Yes Yes Yes Yes