漂浮广告(一)



<DIV id=img style=position:absolute;width:120;height:69px;left:12;top:3><a href="../sg.htm" target="_blank"><img border=0 src=img/1231.gif width=147 height=68 alt=></a>
<SCRIPT language=JavaScript>          
<!-- Begin          
var xPos=20;var yPos=document.body.clientHeight;var step=1;var delay=40;var height=0;var Hoffset=0;var Woffset=0;var yon=0;var xon=0;var pause=true;var interval;img.style.top=yPos;function changePos(){width=document.body.clientWidth;height=document.body.clientHeight;Hoffset=img.offsetHeight;Woffset=img.offsetWidth;img.style.left=xPos+document.body.scrollLeft;img.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 start(){img.visibility='visible';interval=setInterval('changePos()',delay);}start();//--></SCRIPT></div>









漂浮广告(二)






<div id="ad" style="position:absolute"> <a href="​​http://xu-ni.net​​​" target="_blank"> <img src="​​​http://xu-ni.net/bbs/skins/copyright.gif​​" border="0"> </a></div> <script> var x = 50,y = 60 var xin = true, yin = true var step = 1 var delay = 10 var obj=document.getElementByIdx_x("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.οnmοuseοver=function(){clearInterval(itl)} obj.οnmοuseοut=function(){itl=setInterval("floatAD()", delay)} </script>

把上面的代码放在需要放置广告的页面HTML代码的<body></body>之间



-----上面的代码说明-------



​http://xu-ni.net​​ //换成是漂浮图片点击后出现的页面,也就是点击后出现的详细的介绍页面


​http://xu-ni.net/bbs/skins/copyright.gif​​ //换成是漂浮广告图片的URL地址,最好采用绝对路径


var x = 50,y = 60 //浮动层的初始位置,分别对应层的初始X坐标和Y坐标



var xin = true, yin = true //判断层的X坐标和Y坐标是否在在控制范围之内,xin为真是层向右移动,否则向左;yin为真是层向下移动,否则向上


var step = 1 //层移动的步长,值越大移动速度越快


var delay = 10 //层移动的时间间隔,单位为毫秒,值越小移动速度越快