-
Notifications
You must be signed in to change notification settings - Fork 0
/
12.延时提示框.html
71 lines (66 loc) · 1.38 KB
/
12.延时提示框.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
div{
float: left;
margin: 10px;
}
#div1{
width: 50px;
height: 50px;
background: red;
}
#div2{
width: 250px;
height: 180px;
background: #CCCCCC;
display: none;
}
</style>
<script type="text/javascript">
window.onload=function(){
var oDiv1=document.getElementById("div1");
var oDiv2=document.getElementById("div2");
var timer=null;
/*
oDiv1.onmouseover=function (){
clearTimeout(timer);
oDiv2.style.display="block";
}
oDiv1.onmouseout=function(){
timer=setTimeout(function(){
oDiv2.style.display="none";
},500);
}
oDiv2.onmouseover=function(){
clearTimeout(timer);
oDiv2.style.display="block";
}
oDiv2.onmouseout=function(){
timer=setTimeout(function(){
oDiv2.style.display="none";
},500);
}*/
//简化
oDiv1.onmouseover=oDiv2.onmouseover=function (){
clearTimeout(timer);
oDiv2.style.display="block";
}
oDiv1.onmouseout=oDiv2.onmouseout=function(){
timer=setTimeout(function(){
oDiv2.style.display="none";
},500);
}
}
</script>
<title></title>
</head>
<body>
<div id="div1">
</div>
<div id="div2">
</div>
</body>
</html>