用js实现控制内容的向上向下滚动效果
2007-06-26 00:00
926 查看
<SCRIPT language=JavaScript1.2>
iens6=document.all||document.getElementById
ns4=document.layers
//specify speed of scroll (greater=faster)
var speed=10
if (iens6){
document.write('<div id="container" style="position:relative;width:600;height:430;border:0px solid black;overflow:hidden">')
document.write('<div id="content" style="position:absolute;width:590;left:0;top:0">')
}
</SCRIPT>
<SCRIPT language=JavaScript1.2>
if (iens6)
document.write('</div></div>')
</SCRIPT>
<SCRIPT language=JavaScript1.2>
if (iens6){
var crossobj=document.getElementById? document.getElementById("content") : document.all.content
var contentheight=crossobj.offsetHeight
}
else if (ns4){
var crossobj=document.nscontainer.document.nscontent
var contentheight=crossobj.clip.height
}
function movedown(){
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",100)
}
function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",100)
}
function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}
window.onload=getcontent_height
</SCRIPT>
iens6=document.all||document.getElementById
ns4=document.layers
//specify speed of scroll (greater=faster)
var speed=10
if (iens6){
document.write('<div id="container" style="position:relative;width:600;height:430;border:0px solid black;overflow:hidden">')
document.write('<div id="content" style="position:absolute;width:590;left:0;top:0">')
}
</SCRIPT>
<SCRIPT language=JavaScript1.2>
if (iens6)
document.write('</div></div>')
</SCRIPT>
<SCRIPT language=JavaScript1.2>
if (iens6){
var crossobj=document.getElementById? document.getElementById("content") : document.all.content
var contentheight=crossobj.offsetHeight
}
else if (ns4){
var crossobj=document.nscontainer.document.nscontent
var contentheight=crossobj.clip.height
}
function movedown(){
if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
crossobj.style.top=parseInt(crossobj.style.top)-speed
else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",100)
}
function moveup(){
if (iens6&&parseInt(crossobj.style.top)<=0)
crossobj.style.top=parseInt(crossobj.style.top)+speed
else if (ns4&&crossobj.top<=0)
crossobj.top+=speed
moveupvar=setTimeout("moveup()",100)
}
function getcontent_height(){
if (iens6)
contentheight=crossobj.offsetHeight
else if (ns4)
document.nscontainer.document.nscontent.visibility="show"
}
window.onload=getcontent_height
</SCRIPT>
相关文章推荐
- 用js实现控制内容的向上向下滚动效果
- JS实现“鼠标控制局部文字滚动效果”研究
- 使用js实现带有停顿效果的图片滚动(按钮控制)
- JS实现文本内容上下滚动效果
- js实现可控制左右方向的无缝滚动效果
- js实现Select列表内容自动滚动效果代码
- js实现新增内容滚动播放效果
- js实现按钮控制带有停顿效果的图片滚动
- js实现内容滚动效果
- JS实现的新浪微博大厅文字内容滚动效果代码
- JS实现的新浪微博大厅文字内容滚动效果代码
- 用JS和CSS实现页面的向上向下滚动效果
- 使用js实现带有停顿效果的图片滚动(按钮控制)
- js实现Select列表内容自动滚动效果代码
- JS实现的另类手风琴效果网页内容切换代码
- js实现类似新浪微博首页内容渐显效果的方法
- js如何实现网站title的滚动效果
- 用js实现类似新浪微博首页内容渐显效果
- [原创]分别用marquee和div+js实现首尾相连循环滚动效果,仅3行代码
- swiper实现局部内容滚动效果