HTML oncontextmenu Attribute

❮ HTML Attributes


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


The oncontextmenu attribute is called when a context menu is invoked generally by right-click. Can be fired by direct targeting of the element or the event bubbling up.

Standard Syntax

<element oncontextmenu="script">

Browser Support


Applies to:

The oncontextmenu attribute can be used on the following element:

Element Attribute
All HTML elements oncontextmenu

Attribute Values

Value Description
script Specifies the script to be run on oncontextmenu
❮ HTML Attributes