HTML event attribute onshow

The onshow attribute event is triggered when a <menu> element is shown as a context menu.

What's new in HTML5

The onshow attribute is new in HTML5.


<menu onshow="script or Javascript function name">

Supported Tags


Browser compatibility

onshow No No 8.0 No No


<!DOCTYPE html>
div {<!--from   w  ww.j a  v a 2s.c o  m-->
    background: yellow;
    border: 1px solid #cccccc;
    padding: 10px;

<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 from custom menu" onclick="" icon=""></menuitem>


function myFunction() {
    console.log("The context menu is about to be shown");


Click to view the demo