手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >用js实现控制内容的向上向下滚动效果
用js实现控制内容的向上向下滚动效果
摘要:iens6=document.all||document.getElementByIdns4=document.layers//specif...

<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>

【用js实现控制内容的向上向下滚动效果】相关文章:

javascript实现设置、获取和删除Cookie的方法

jQuery实现表格行上下移动和置顶效果

javascript实现带下拉子菜单的导航菜单效果

jQuery实现不断闪烁文字的方法

JS+CSS实现的拖动分页效果实例

js+html5实现canvas绘制圆形图案的方法

javascript实现日期按月份加减

纯javascript实现四方向文本无缝滚动效果

js实现带按钮的上下滚动效果

JS实现简洁、全兼容的拖动层实例

精品推荐
分类导航