实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style>
5
div {
6
    background: yellow;
7
    border: 1px solid #cccccc;
8
    padding: 10px;
9
}
10
</style>
11
</head>
12
<body>
13
14
<p>该实例演示了如何使用 addEventListener() 方法向 menu 元素中添加 "onshow" 事件。</p>
15
16
<div contextmenu="mymenu">
17
<p>用鼠标右键单击黄色框区域查看上下文菜单!</p>
18
19
<menu type="context" id="mymenu">
20
  <menuitem label="Refresh" onclick="window.location.reload();" icon="ico_reload.png"></menuitem>
21
  <menu label="Share on...">
22
    <menuitem label="Twitter" icon="ico_twitter.png" onclick="window.open('//twitter.com/intent/tweet?text=' + window.location.href);"></menuitem>