var delta=0.1 var collection; function floaters() { this.items = []; this.addItem = function(id,x,y,content) { document.write('
'+content+'
'); var newItem = {}; newItem.object= document.getElementById(id); newItem.x= x; newItem.y= y; this.items[this.items.length]= newItem; } this.play = function() { collection= this.items setInterval('play()',5); } } function play() { for(var i=0;i0?1:-1)*Math.ceil(Math.abs(dx)); followObj.style.left=followObj.offsetLeft+dx; } var bodytop = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; //xhtml1中不支持document.body.scrollTop if(followObj.offsetTop!=(bodytop+followObj_y)) { var dy=(bodytop+followObj_y-followObj.offsetTop)*delta; dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy)); followObj.style.top=followObj.offsetTop+dy; } } } var theFloaters = new floaters(); theFloaters.addItem('followDiv1',10,50,'
在线客服

'); theFloaters.play();