-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.html
More file actions
53 lines (52 loc) · 1.26 KB
/
event.html
File metadata and controls
53 lines (52 loc) · 1.26 KB
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
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id='d1'>
<span id='s1'>span</span>
</div>
<h2>event属性测试</h2>
<hr/>
<div id='event-parent' style='height:300px;width:300px;background-color:#afa;'>
<div id='event-child' style='height:150px;width:150px;background-color:#efe;'></div>
</div>
<script>
var d1=document.getElementById('d1'),
s1=document.getElementById('s1');
d1.onclick=function(event){
var event=event||window.event,
target=event.target||event.srcElement;
alert(1);
}
s1.onclick=function(event){
event.stopPropagation();
alert(2);
}
window.onbeforeunload=function(){
return 'hello'
}
var eventParent=document.getElementById('event-parent');
eventParent.onmouseover=function(event){
event=event||window.event;
console.log(event);
console.log(event.relatedTarget);
// console.log(event.handleObj);
}
eventParent.onmouseleave=function(event){
event=event||window.event;
console.log(event.relatedTarget);
// console.log(event.handleObj);
}
/*document.addEventListener(
'mousedown',
function(event){
alert(event.which);
},
false
);//注意mousedown咸鱼click触发*/
</script>
</body>
</html>