一个JS特效(随滚动条滚动)有时可以,有时无效的疑问

batistutafans 2004-10-03 05:27:57
一个朋友使用动网的论坛,想在论坛上添加一个随滚动条滚动的图片(有链接),可是在有些电脑上就能有这个效果,在有些上只有刚打开这个页面才有,一拉动滚动条,这个跟随的图片就消失了,滚动效果的代码如下:
<script language="JavaScript">
<!-- Written by Myhyli, 2003/07/21. myhyli.blueidea.com -->
<!-- Member Of Blueidea Web Team. -->
<!-- Welcome to www.blueidea.com. -->

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()
{
if(screen.width<=800)
{
for(var i=0;i<collection.length;i++)
{
collection[i].object.style.display = 'no';
}
return;
}
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-106',80,'<a href=http://www.56hx.com target=_blank><img src=../img/bbs-1.gif border=0></a><br><a href=http://www.56hx.com/wlinfo/index.asp target=_blank><img src=../img/bbs-2.gif border=0></a><br><a href=http://www.56hx.com/cllm/index.asp target=_blank><img src=../img/bbs-3.gif border=0></a><br><a href=http://www.56hx.com/job/index.asp target=_blank><img src=../img/bbs-4.gif border=0></a><br><a href=http://www.56hx.com/wlsb/index.asp target=_blank><img src=../img/bbs-5.gif border=0></a><br><a href=http://www.56hx.com/tcps/index.asp target=_blank><img src=../img/bbs-6.gif border=0></a><br><a href=http://www.56hx.com/huangye/index.asp target=_blank><img src=../img/bbs-7.gif border=0></a>');
theFloaters.play();
</script>

具体的地址在www.56hx.com.cn/56bbs/, 他让我帮忙看问题在哪里,我看了一下没看出来,请教大家,是不是跟浏览器版本、分辨率有关系,还是跟操作系统有关系,多谢!
...全文
164 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nhconch 2004-10-03
  • 打赏
  • 举报
回复
http://blog.csdn.net/nhconch/archive/2004/07/06/35350.aspx
batistutafans 2004-10-03
  • 打赏
  • 举报
回复
对了,他是把这些代码写成JS文件,用INCLUDE的方式来调用的

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧