<div contextmenu="mymenu"> <p>用鼠标右键单击黄色框区域查看上下文菜单</p> <menu type="context" id="mymenu" onshow="myFunction()"> <menuitem label="Refresh" onclick="window.location.reload();" icon="ico_reload.png"> <menu label="分享..."> <menuitem label="Twitter" icon="ico_twitter.png" onclick="window.open('//twitter.com/intent/tweet?text=' + window.location.href);"> <menuitem label="Facebook" icon="ico_facebook.png" onclick="window.open('//facebook.com/sharer/sharer.php?u=' + window.location.href);"> </menu> <menuitem label="发邮件到该页面" onclick="window.location='mailto:?body='+window.location.href;"> </menu> </div> <p><strong>注意:</strong>目前只有 Firefox 浏览器支持 onshow 属性。</p> <script> function myFunction() { alert("上下文菜单即将显示"); } </script>