求能在网页左右两边跟随页面一起滚动的图片(网页)的js代码
如题,即可给分。 问题点数:100、回复次数:6Top
1 楼pangyong0221(Forget)回复于 2006-06-01 09:48:52 得分 90
//左边
//左边
//var left_img='<a href=http://www.020.cn target=_blank><img src=http://www.ddvip.net/ad/020cn.gif border=0></a><br><br><a href=http://vip.ddvip.net target=_blank><img src=http://www.ddvip.net/ad/vip/vip.gif border=0>';
//
//
//右边
var right_img='<a href=http://www.aaaaaa.com target=_blank><img src=/ad/100X1002005.1.gif border=0></a>';
var delta=0.15
var collection;
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);
newItem.x = x;
newItem.y = y;
this.items[this.items.length] = newItem;
}
this.play = function()
{
collection = this.items
setInterval('play()',10);
}
}
function play()
{
for(var i=0;i<collection.length;i++)
{
var followObj = collection[i].object;
var followObj_x = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
var followObj_y = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
followObj.style.left=followObj.offsetLeft+dx;
}
if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) {
var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta;
dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
followObj.style.top=followObj.offsetTop+dy;
}
followObj.style.display = '';
}
}
var theFloaters = new floaters();
theFloaters.addItem('followDiv1','document.body.clientWidth-108',180,''+right_img+'');
//theFloaters.addItem('followDiv2','10',100,''+left_img+'');
theFloaters.play();Top
2 楼net_lover(【孟子E章】)回复于 2006-06-01 09:52:10 得分 10
找一个有这样效果的网站,查看源代码即可,是客户端js做的Top
3 楼ilovejolly(有些伤感)回复于 2006-06-01 09:55:39 得分 0
同上Top
4 楼andrew1230()回复于 2006-06-01 09:56:06 得分 0
好的,我来找找。给分,哈哈Top
5 楼lazyfish(呆呆虫)回复于 2006-06-01 09:57:48 得分 0
给分Top
6 楼waxln(有点意思)回复于 2006-06-01 10:00:15 得分 0
帮定Top




