新微赢技术网
标题:
[求助]浮动广告
[打印本页]
作者:
.`D.D`地`
时间:
2010-1-15 04:54
标题:
[求助]浮动广告
<script language="JavaScript">
var delta=0.15
var layers;
function floaters() {
this.items= [];
this.addItem= function(id,x,y,content)
{
document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute; width:80px; height:60px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
var newItem= {};
newItem.object= document.getElementById(id);
if(y>10) {y=0}
newItem.x= x;
newItem.y= y;
this.items[this.items.length]= newItem;
}
this.play= function()
{
layers= this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<layers.length;i++)
{
var obj= layers[i].object;
var obj_x= (typeof(layers[i].x)=='string'?eval(layers[i].x):layers[i].x);
var obj_y= (typeof(layers[i].y)=='string'?eval(layers[i].y):layers[i].y);
if(obj.offsetLeft!=(document.body.scrollLeft+obj_x)) {
var dx=(document.body.scrollLeft+obj_x-obj.offsetLeft)*delta;
dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
obj.style.left=obj.offsetLeft+dx;
}
if(obj.offsetTop!=(document.body.scrollTop+obj_y)) {
var dy=(document.body.scrollTop+obj_y-obj.offsetTop)*delta;
dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
obj.style.top=obj.offsetTop+dy;
}
obj.style.display= '';
}
}
var strfloat = new floaters();
strfloat.addItem('followDiv',6,80,'<img src=zhuce.gif border=0>');
strfloat.play();
</script>
怎样改之后,是一边个一个同样的图呀,并一起浮动。
欢迎光临 新微赢技术网 (http://bbs.weiying.cn/)
Powered by Discuz! X3.2