-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevent-contextmenu.html
43 lines (38 loc) · 1.26 KB
/
event-contextmenu.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!doctype html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>click vs contextmenu</title>
<style>
#contextMenu {
height: 100px;
}
#log {
/* position: fixed;
left: 0px;
bottom: 0px; */
}
</style>
</head>
<body>
<p id="log">Log</p>
<p>
<svg id="contextMenu" version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="200px" height="100px">
<rect class="block" x="0" y="0" fill="#ff6347" width="100" height="100" />
<rect class="block" x="100" y="0" fill="#a8eaff" width="100" height="100" />
</svg>
</p>
<script>
"use strict";
let contextMenuElement = document.getElementById('contextMenu');
let logElement = document.getElementById('log');
contextMenuElement.addEventListener('click', e => {
logElement.innerText = 'Click event at ' + new Date().toUTCString();
});
contextMenuElement.addEventListener('contextmenu', e => {
logElement.innerText = 'Context menu event at ' + new Date().toUTCString();
});
</script>
</body>
</html>