这个滑动层总是在最上部,如何修改让它在文档中间显示或者离上面有一定距离?

CPerlAsm_Lx 2004-10-15 06:16:14
<SCRIPT LANGUAGE="JavaScript">
<!--
function divmove()
{
cc=parseInt(document.body.scrollTop - div1.offsetTop);
if(cc==-1 || cc==1 || cc==0)
{div1.style.top=document.body.scrollTop;}
else
{
if(cc>0 && cc>50)
{bb=20;}
else if(cc<0 && cc<-50)
{bb=-20;}
else if(cc>10 && cc<50)
{bb=5;}
else if(cc<-10 && cc>-50)
{bb=-5;}
else if(cc>0 && cc<10)
{bb=2;}
else if(cc<0 && cc>-10)
{bb=-2;}
div1.style.top = div1.offsetTop + bb;
}

setTimeout("divmove()",1);
}
//-->
</SCRIPT>
...全文
107 点赞 收藏 4
写回复
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2004-10-15
<body onload="divmove()">
<div id=div1 style="position:absolute">dddddddd</div>
<SCRIPT LANGUAGE="JavaScript">
<!--

function divmove()
{
cc=parseInt(document.body.scrollTop);
div1.style.top = document.body.offsetHeight/2 + cc;
setTimeout("divmove()",1);
}
//-->
</SCRIPT>
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
</body>
回复
孟子E章 2004-10-15
<body onload="divmove()">
<div id=div1 style="position:absolute">dddddddd</div>
<SCRIPT LANGUAGE="JavaScript">
<!--

function divmove()
{
cc=parseInt(document.body.scrollTop);
div1.style.top = 100 + cc;
setTimeout("divmove()",1);
}
//-->
</SCRIPT>
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok<p>ok
</body>
回复
CPerlAsm_Lx 2004-10-15
net_lover(孟子E章)
这样不幸,乱跳!
回复
孟子E章 2004-10-15
div1.style.top = div1.offsetTop + bb+100
回复
发动态
发帖子
JavaScript
创建于2007-09-28

8.4w+

社区成员

Web 开发 JavaScript
申请成为版主
社区公告
暂无公告