-
Notifications
You must be signed in to change notification settings - Fork 6
/
009-延时提示框.html
54 lines (51 loc) · 1001 Bytes
/
009-延时提示框.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
#div1{ width:200px; height:30px; background:red;}
#div2{ width:150px; height:20px; background:#ccc; display:none; margin-top:20px;}
</style>
<script>
window.onload = function ()
{
var oDiv1 = document.getElementById("div1");
var oDiv2 = document.getElementById("div2");
var timer = null;
<!--
function show()
{
clearTimeout(timer);
oDiv2.style.display = "block";
}
function hide()
{
timer = setTimeout(function(){
oDiv2.style.display = "none";
},500);
}
oDiv1.onmouseover = show;
oDiv1.onmouseout = hide;
oDiv2.onmouseover = show;
oDiv2.onmouseout = hide;
-->
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>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
</body>
</html>