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.

Syntax

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

Supported Tags

<menu>

Browser compatibility

onshow No No 8.0 No No




Example

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

<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>
    </menu>

</div>


<script>
function myFunction() {
    console.log("The context menu is about to be shown");
}
</script>

</body>
</html>

Click to view the demo