用js實(shí)現(xiàn)控制內(nèi)容的向上向下滾動(dòng)效果
更新時(shí)間:2007年06月26日 00:00:00 作者:
<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>
相關(guān)文章
獲取 textarea 標(biāo)簽第n行的文字的js代碼
獲取 textarea 標(biāo)簽第n行的文字的實(shí)現(xiàn)代碼,非常的不錯(cuò),兼容了firefox.2009-08-08更換select下拉菜單背景樣式的實(shí)現(xiàn)代碼
更換select下拉菜單背景樣式的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-12-12Javascript實(shí)現(xiàn)圖片不間斷滾動(dòng)的代碼
這篇文章主要分享一段js圖片不間斷滾動(dòng)的代碼,蠻優(yōu)秀的,需要的朋友可以參考下。2016-06-06勾選時(shí)激活input 否則禁用的javascript代碼
唯一的可去之外是加了一點(diǎn)美化,使用戶體驗(yàn)更加一層樓,其中包括邊框的加粗,焦點(diǎn)的獲取,checkbox邊框線的隱藏等等。2009-12-12