-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhtml.html
More file actions
43 lines (42 loc) · 806 Bytes
/
html.html
File metadata and controls
43 lines (42 loc) · 806 Bytes
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>
<html>
<head>
<title>右键菜单</title>
<style>
#div{
width:80px;
height: 100px;
background: #ccc;
border: 1px solid #FF0000;
display: none;
position: absolute;
}
li{
list-style: none;
}
</style>
</head>
<body>
<div id="div">
<ul>
<li>asdfsd</li>
</ul>
</div>
<script type="text/javascript">
window.onload = function(){
document.oncontextmenu = function(e){
var oEvent = window.ev||event;
var oDiv = document.getElementById('div');
oDiv.style.display = 'block';
oDiv.style.left = oEvent.clientX + 'px';
oDiv.style.top = oEvent.clientY + 'px';
return false;
}
document.onclick = function(){
var oDiv = document.getElementById('div');
oDiv.style.display = 'none';
}
}
</script>
</body>
</html>