``` --- ## Definition and Usage"> ``` --- ## Definition and Usage" />
Easy Tutorial
❮ Prop Pushbutton Type Jsref Tolocaledatestring ❯

oncontextmenu Event

Event Object

Example

Execute JavaScript when the user right-clicks on a <div> element:

<div oncontextmenu="myFunction()" contextmenu="mymenu">

Definition and Usage

The oncontextmenu event is triggered when the user right-clicks on an element to open the context menu.

Note: All browsers support the oncontextmenu event, but the contextmenu attribute is only supported by Firefox.


Browser Support

Event
oncontextmenu Yes Yes Yes Yes Yes

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: Internet Explorer 8 and earlier versions do not support the addEventListener() method.


Technical Details

Bubbles: Yes
Cancelable: Yes
--- ---
Event Type: MouseEvent
--- ---
Supported HTML Tags: All HTML elements
--- ---

Event Object

❮ Prop Pushbutton Type Jsref Tolocaledatestring ❯