-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
56 lines (51 loc) · 1.37 KB
/
test.html
File metadata and controls
56 lines (51 loc) · 1.37 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
54
55
56
<html>
<head>
<title>漂浮广告代码</title>
</head>
<body>
<div id="ad" style="position:absolute">
<a href="http://www.cxyblog.com/">
<img src="./image/avatar1.jpg" />
</a>
</div>
<script>
var x = 50,
y = 60
var xin = true,
yin = true
var step = 1
var delay = 50
var obj = document.getElementById("ad")
function floatAD() {
var L = T = 0
var R = document.body.clientWidth - obj.offsetWidth
var B = document.body.clientHeight - obj.offsetHeight
obj.style.left = x + document.body.scrollLeft
obj.style.top = y + document.body.scrollTop
x = x + step * (xin ? 1 : -1)
if (x < L) {
xin = true;
x = L
}
if (x > R) {
xin = false;
x = R
}
y = y + step * (yin ? 1 : -1)
if (y < T) {
yin = true;
y = T
}
if (y > B) {
yin = false;
y = B
}
}
var itl = setInterval("floatAD()", delay)
obj.onmouseover = function floatStop() {}
obj.onmouseout = function () {
itl = setInterval("floatAD()", delay)
}
</script>
</body>
</html>