当<menu>元素在HTML中显示为上下文菜单时,将触发onshow事件。
当<menu>元素显示为上下文菜单时,您可以尝试运行以下代码来执行脚本-
<!Doctype html> <html> <head> <title>HTML menu</title> </head> <body> <div style = "border:1px solid #000; padding:20px;" contextmenu = "clickmenu"> <p>Right click inside here....</p> <menu type = "context" id = "clickmenu" onshow="display()"> <menuitem label = "Nhooo" onclick = ""></menuitem> <menuitem label = "Tutorials Library" onclick = ""></menuitem> <menuitem label = "Coding Ground" onclick = ""></menuitem> <menuitem label = "Q/A" onclick = ""></menuitem> </menu> </div> <script> function display() { alert("上下文菜单现在将可见。"); } </script> </body> </html>