觸發(fā) 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>
更多建議: