您的位置:首页 > Web前端 > JavaScript

js浮动广告

2006-06-15 13:07 190 查看
<DIV id=wcimg style="POSITION: absolute">aaaaaaa</DIV>
<SCRIPT language=javascript>
<!--
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 10;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var wcinterval;
wcimg.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = wcimg.offsetHeight;
Woffset = wcimg.offsetWidth;
wcimg.style.left = xPos + document.body.scrollLeft;
wcimg.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function wcstart() {
wcimg.visibility = "visible";
wcinterval = setInterval('changePos()', delay);
}
wcstart();
// End -->
</SCRIPT>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: