English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
当一个具有contextmenu属性的元素的contextmenu事件触发或冒泡到该元素时,show事件会被触发。
当 <menu> 元素在上下文菜单显示时执行 JavaScript:
!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>基础教程(oldtoolbag.com)</title> </head> <body> <div contextmenu="test"></div> <menu type="context" id="test"> <menuitem label="alert" onclick="alert('the alert label has been clicked');" /> </menu> <script> document.getElementById("test").addEventListener("show", function(e){ alert("le menu contextuel sera affiché"); }, false); </script> </body> </html>Voyons voir ‹/›
Lorsque l'élément <menu> est affiché comme un menu contextuel, la propriété onshow est activée.
IEFirefoxOperaChromeSafari
Actuellement, seuls les navigateurs Firefox prennent en charge la propriété d'événement onshow.
Les propriétés d'événement onshow sont dans HTML5nouvelles fonctionnalités ajoutées.
<element onshow="script">
Valeur | Description |
---|---|
script | Le script s'exécute dans onshow |
Balises HTML prises en charge: | <menu> |
---|
Manuel de référence HTML DOM Événement onshow