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

Related Articles
List of Form Events Attribute Form Events Attribute
HTML onblur Event Attribute Form Events Attribute
HTML onchange Event Attribute Form Events Attribute
HTML oncontextmenu Event Attribute Form Events Attribute

Single Articles
Example of HTML oncontextmenu Event AttributeForm Events Attribute
Definition and Usage of HTML oncontextmenu Event AttributeForm Events Attribute
Browser Support of HTML oncontextmenu Event AttributeForm Events Attribute
Syntax of HTML oncontextmenu Event AttributeForm Events Attribute
Syntax of HTML oncontextmenu Event AttributeForm Events Attribute
Syntax of HTML oncontextmenu Event AttributeForm Events Attribute

Read Full:
Form Events Attribute
Type:
Develop
Category:
Web Tutorial
Sub Category:
Form Events Attribute
Uploaded by:
Admin
Views:
22


Reffered: https://www.w3schools.com/tags/ev_oncontextmenu.asp