代码示例:(标识:event_onshow_dom)
<!DOCTYPE html>
<html>
<head>
<style>
div {
  background: yellow;
  border: 1px solid #cccccc;
  padding: 10px;
}
</style>
</head>
<body>
本例使用 HTML DOM 将“onshow”事件分配给菜单元素。
<p>This example uses the HTML DOM to assign an "onshow" event to a menu element.</p>
在此框中右键单击以查看上下文菜单!
<div contextmenu="mymenu">
<p>Right-click inside this box to see the context menu!

<menu type="context" id="mymenu">
  <menuitem label="Refresh" onclick="window.location.reload();" icon="ico_reload.png"></menuitem>
  <menu label="Share on...">
    <menuitem label="Twitter" icon="ico_twitter.png" onclick="window.open('//twitter.com/intent/tweet?text=' + window.location.href);"></menuitem>
    <menuitem label="Facebook" icon="ico_facebook.png" onclick="window.open('//facebook.com/sharer/sharer.php?u=' + window.location.href);"></menuitem>
  </menu>
  <menuitem label="Email This Page" onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
</menu>

</div>
onshow 事件目前仅在 Firefox 中受支持。
<p><b>注释:</b>onshow 事件目前仅在 Firefox 中受支持。</p>

<script>
document.getElementById("mymenu").onshow = function() {myFunction()};

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

</body>
</html>
运行结果: