当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 用js实现控制内容的向上向下滚动效果

Javascript
比较精简的Javascript拖动效果函数代码
一个可以得到元素真实的背景颜色的javascript脚本
代码精简的可以实现元素圆角的js函数
用JS实现的一个include函数
IE 缓存策略的BUG的解决方法
$()JS小技巧
js右键菜单效果代码
XML的代替者----JSON
清空代码防止查看源代码的js代码
一个JS翻页效果
用js获取点击图片的值!
用innerHTML &符号副值给文本框后会变成&的方法
让iframe自适应高度(支持XHTML,支持FF)
dsfasdfasdf
用ASP将SQL搜索出来的内容导出为TXT的代码
弹出广告特效(一个IP只弹出一次)的代码
javascript实现的动态文字变换
服务器安全设置的几个注册表设置
取键盘键位ASCII码的网页
用倒置滤镜把div倒置,再把table倒置。

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 60 ::
收藏到网摘: n/a

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