浮动广告实例
style="Z-INDEX: 100;
LEFT: 12px;
WIDTH: 159px;
POSITION: absolute;
TOP: 143px;
HEIGHT: 161px;
visibility: visible;">
<script><BR>var xPos = 0;<BR>var yPos = 0;<BR>var step = 3;<BR>var delay = 100;<BR>var height = 0;<BR>var Hoffset = 0;<BR>var Woffset = 0;<BR>var yon = 0;<BR>var xon = 0;<BR>var pause = true;<BR>var interval;<BR>img1.style.top = yPos;<BR>function changePos()<BR>{<BR> width = document.body.clientWidth; //获取浏览器的宽度<BR> height = document.body.clientHeight; //获取浏览器的高度<BR>Hoffset = img1.offsetHeight;<BR>Woffset = img1.offsetWidth;<BR>img1.style.left = xPos + document.body.scrollLeft;<BR>img1.style.top = yPos + document.body.scrollTop;<BR>if (yon)<BR>{yPos = yPos + step;}<BR>else<BR>{yPos = yPos - step;}<BR>if (yPos < 0)<BR>{yon = 1;yPos = 0;}<BR>if (yPos >= (height - Hoffset))<BR>{yon = 0;yPos = (height - Hoffset);}<BR>if (xon)<BR>{xPos = xPos + step;}<BR>else<BR>{xPos = xPos - step;}<BR>if (xPos < 0)<BR>{xon = 1;xPos = 0;}<BR>if (xPos >= (width - Woffset))<BR>{xon = 0;xPos = (width - Woffset); }<BR>}<BR>function start()<BR>{<BR>img1.visibility = "visible";<BR>interval = setInterval('changePos()', delay);<BR>//interval = setTimeout("changePos()", delay);<BR>}<BR>function pause_resume()<BR>{<BR>if(pause)<BR>{<BR>clearInterval(interval);<BR>pause = false;}<BR>else<BR>{<BR>interval = setInterval('changePos()',delay);<BR>pause = true;<BR>}<BR>}<BR>start();<BR></script>