用js实现控制内容的向上向下滚动效果

时间:2021-05-18

<SCRIPTlanguage=JavaScript1.2>
iens6=document.all||document.getElementById
ns4=document.layers

//specifyspeedofscroll(greater=faster)
varspeed=10

if(iens6){
document.write('<divid="container"style="position:relative;width:600;height:430;border:0pxsolidblack;overflow:hidden">')
document.write('<divid="content"style="position:absolute;width:590;left:0;top:0">')
}
</SCRIPT>
<SCRIPTlanguage=JavaScript1.2>
if(iens6)
document.write('</div></div>')
</SCRIPT>
<SCRIPTlanguage=JavaScript1.2>
if(iens6){
varcrossobj=document.getElementById?document.getElementById("content"):document.all.content
varcontentheight=crossobj.offsetHeight
}
elseif(ns4){
varcrossobj=document.nscontainer.document.nscontent
varcontentheight=crossobj.clip.height
}

functionmovedown(){
if(iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
elseif(ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",100)
}

functionmoveup(){
if(iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
elseif(ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",100)

}

functiongetcontent_height(){
if(iens6)
contentheight=crossobj.offsetHeight
elseif(ns4)
document.nscontainer.document.nscontent.visibility="show"
}
window.onload=getcontent_height
</SCRIPT>

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章