onshow Event

Definition and Usage

An onshow event occurs when the <menu> element is displayed as a context menu.

Example

Execute JavaScript when the <menu> element is displayed as a context menu:

<div contextmenu="mymenu">
  <p>Right-click inside this box to see the context menu!</p>
  <menu type="context" id="mymenu" onshow="myFunction()">
    <menuitem label="Refresh" onclick="window.location.reload();"></menuitem>
  </menu>
</div>

Try It Yourself

Syntax

In HTML:

<element onshow="myScript">

Try It Yourself

In JavaScript:

object.onshow = function(){myScript};

Try It Yourself

In JavaScript, use the addEventListener() method:

object.addEventListener("show", myScript);

Try It Yourself

Note:Internet Explorer 8 or earlier versions do not support addEventListener() Method.

Technical Details

Bubbling: Not Supported
Cancelable: Not Supported
Event Type: Event
Supported HTML Tags: <menu>
DOM Version: Level 3 Events

Browser Support

The numbers in the table indicate the first browser version that fully supports this event.

Event Chrome IE Firefox Safari Opera
onshow Not Supported Not Supported 8.0 Not Supported Not Supported

Related Pages

HTML Reference Manual: HTML contextmenu Attribute

HTML Reference Manual: HTML <menu> Tag