<menu onshow="myFunction()"> - Javascript DOM Event

Javascript examples for DOM Event:onshow

Description

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

Summary

Bubbles No
Cancelable No
Supported HTML tags: <menu>

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {/*  w  w  w.ja v a 2 s.  co  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!

<menu type="context" id="mymenu" onshow="myFunction()">
  <menuitem label="Refresh" onclick="window.location.reload();" icon=""></menuitem>
  <menu label="Sub menu">
    <menuitem label="A" icon="" onclick="console.log('a')"></menuitem>
    <menuitem label="B" icon="" onclick="console.log('b')"></menuitem>
  </menu>
  <menuitem label="C" onclick="console.log('c')"></menuitem>
</menu>

</div>

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

</body>
</html>

Related Tutorials