Horje
HTML oncontextmenu Event Attribute

The oncontextmenu event attribute in HTML is used to specify a JavaScript function or script to be executed when the user right-clicks on an element, triggering the context menu. This event allows developers to customize or prevent the default browser context menu behavior


Example of HTML oncontextmenu Event Attribute

It will execute a JavaScript when a context menu is triggered.
index.html
Example: HTML
 <div oncontextmenu="myFunction()" contextmenu="mymenu"> 

Output should be:

Example of HTML oncontextmenu Event Attribute

Definition and Usage of HTML oncontextmenu Event Attribute

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.

Browser Support of HTML oncontextmenu Event Attribute

Browser Support of HTML oncontextmenu Event Attribute

Syntax of HTML oncontextmenu Event Attribute

< element oncontextmenu=" script ">

Syntax of HTML oncontextmenu Event Attribute

< element oncontextmenu=" script ">

Syntax of HTML oncontextmenu Event Attribute

< element oncontextmenu=" script ">





html event attributes

Type :
Develop
Category :
Web Tutorial
Sub Category :
HTML Form Events Attribute
Uploaded by :
Admin


Read Article
https://horje.com/learn/1434/reference