触发 onshow
属性事件当< menu> 元素显示为上下文菜单。
onshow属性是HTML5中的新特性。
<menu onshow="script or Javascript function name">
<menu>
onshow |
No | No | 8.0 | No | No |
<!DOCTYPE html>
<html>
<head>
<style>
div {
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>