在确定上下文菜单后,使用HTML5中的contextmenu属性执行脚本。当用户右键单击时,将生成一个上下文菜单。
您可以尝试运行以下代码以实现contextmenu属性-
<!Doctype html> <html> <head> <title>HTML menuitem Tag</title> </head> <body> <div style = "border:1px solid #000; padding:20px;" contextmenu = "clickmenu"> <p>Right click inside here....</p> <menu type = "context" id = "clickmenu"> <menuitem label = "Nhooo" onclick = ""></menuitem> <menuitem label = "教程库" onclick = ""></menuitem> <menuitem label = "编码地面" onclick = ""></menuitem> <menuitem label = "Q/A" onclick = ""></menuitem> </menu> </div> </body> </html>