Javascript examples for DOM Event:Element Event Attribute
The onshow event occurs when a <menu> element is shown as a context menu.
Bubbles | No |
---|---|
Cancelable | No |
Supported HTML tags: | <menu> |
<!DOCTYPE html> <html> <head> <style> div {/* w w w . ja va2 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> document.getElementById("mymenu").onshow = function() {myFunction()}; function myFunction() { console.log("The context menu is about to be shown"); } </script> </body> </html>