The onshow
attribute event is triggered
when a <menu> element is shown as a context menu.
The onshow attribute is new in HTML5.
<menu onshow="script or Javascript function name">
<menu>
onshow |
No | No | 8.0 | No | No |
<!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>