Element: contextmenu event

The contextmenu event fires when the user attempts to open a context menu.

This event is typically triggered by clicking the right mouse button, or by pressing the context menu key. (In the latter case, the context menu is displayed at the bottom left of the focused element, unless the element is a tree, in which case the context menu is displayed at the bottom left of the current row.)

Note that this event will occur with any non-disabled right-click event and does not depend on an element possessing the contextmenu attribute.

Bubbles Yes
Cancelable Yes
Interface MouseEvent
Event handler property oncontextmenu

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'contextmenu' in that specification.
Living Standard  

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Edge Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)
On disabled form elements (Yes)[1] No support (Yes) No support (Yes)[1] ?
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) ? ? ? ?
On disabled form elements ? No support ? ? ? ?

[1] Only works for <textarea> elements and some <input> element types.

In Gecko this event is handled by an XUL ancestor element, even for HTML5 context menus, which are actually handled by the browser element's context menu. If an XUL ancestor element has a context or contextmenu attribute referencing a popup, then it will display when this event occurs (subject to the popupshowing event).

See also

Document Tags and Contributors

Last updated by: mdnwebdocs-bot,