js学习笔记28----事件默认行为
2021-06-16 04:04
标签:lock doctype ntb initial abs func window order width js学习笔记28----事件默认行为 标签:lock doctype ntb initial abs func window order width 原文地址:http://www.cnblogs.com/sese/p/7271701.html 1 DOCTYPE html>
2 html lang="en">
3 head>
4 title>事件默认行为title>
5 meta charset="UTF-8">
6 meta name="viewport" content="width=device-width, initial-scale=1">
7 style style="text/css">
8 #div1{width: 100px;height: 200px;border: 1px solid #f00;position:absolute;display:none}
9 style>
10 script>
11 window.onload = function(){
12 var oDiv = document.getElementById("div1");
13 document.oncontextmenu = function(ev){
14 var ev = ev || event;
15 oDiv.style.display = "block";
16 oDiv.style.left = ev.clientX + ‘px‘;
17 oDiv.style.top = ev.clientY + ‘px‘;
18 return false;
19 }
20 document.onclick = function(ev){
21 oDiv.style.display = "none";
22 }
23 }
24 script>
25 head>
26 body>
27 div id="div1">
28
29 div>
30 body>
31 html>
上一篇:webIDE 第二篇博文
下一篇:超超简单的php模拟登录