页面两侧对联广告代码效果(1) 现在很多网站广告做的如火如荼,现在我就来介绍一下常见的对联浮动广告效果的代码使用方法,本文介绍的这种效果,在1024*768分辨率下正常显示,在800*600的分辨率下可以自动隐藏,以免遮住页面影响访问者浏览内容,下面文本框中就是实现效果所需代码:<P> var delta=0.015<BR> var collection;<BR> function floaters() {<BR> this.items = [];<BR> this.addItem = function(id,x,y,content)<BR> {<BR> document.write('<DIV id='+id+' style="Z-INDEX: 0; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');<BR> <BR> var newItem = {};<BR> newItem.object = document.getElementById(id);<BR> newItem.x = x;<BR> newItem.y = y;</P><P> this.items[this.items.length] = newItem;<BR> }<BR> this.play = function()<BR> {<BR> collection = this.items<BR> setInterval('play()',10);<BR> }<BR> }<BR> function play()<BR> {<BR> if(screen.width<=800)<BR> {<BR> for(var i=0;i<collection.length;i++)<BR> {<BR> collection[i].object.style.display = 'none';<BR> }<BR> return;<BR> }<BR> for(var i=0;i<collection.length;i++)<BR> {<BR> var followObj = collection[i].object;<BR> var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);<BR> var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);</P><P> if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {<BR> var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;<BR> dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));<BR> followObj.style.left=followObj.offsetLeft+dx;<BR> }</P>