js数据向上翻滚_数据滚动
2010-09-14 13:28:25 来源:WEB开发网<body>
<div>
<ul style="width:500px;height:20px;overflow:hidden;border:1px red solid;line-height:20px;" id="scroll">
<li>脚本之家</li>
<li>jb51.net</li>
<li>看书了</li>
<li>kanshule.com</li>
<li>好好学习</li>
<li>发生大幅6</li>
<li>发生大幅7</li>
<li>发生大幅8</li>
<li>发生大幅9</li>
<li>发生大幅10</li>
<li>发生大幅11</li>
<li>发生大幅12</li>
<li>发生大幅13</li>
<li>发生大幅14</li>
<li>发生大幅15</li>
<li>发生大幅16</li>
<li>发生大幅17</li>
<li>发生大幅18</li>
<li>发生大幅19</li>
<li>发生大幅20</li>
</ul>
<ul id="scroll2"></div>
</div>
<script type="text/javascript">
var scrollDelay=10;//数字越大速度越慢
var Scroll=document.getElementById("scroll");
var Scroll2=document.getElementById("scroll2");
var currentTop=0,preTop=0,stoptime=0,stopscroll=false;
var ScrollChild=Scroll.getElementsByTagName("li");
var ScrollHeight=Scroll.offsetHeight;
function ScrollInfo(){
if(stopscroll==true) return;
currentTop++;
if(currentTop+1>=ScrollHeight){
currentTop--;
stoptime++;
if(stoptime==parseInt(ScrollHeight)*scrollDelay) {
currentTop=0;
stoptime=0;
}
}else{
preTop=Scroll.scrollTop;
Scroll.scrollTop++;
if(preTop==Scroll.scrollTop){
Scroll.scrollTop=Scroll2.offsetHeight-ScrollHeight;
Scroll.scrollTop+=1;
}
}
}
function Int_Scroll(){
Scroll2.innerHTML="";
Scroll2.innerHTML=Scroll.innerHTML;
Scroll.innerHTML=Scroll2.innerHTML+Scroll2.innerHTML;
Scroll.onmouseover=function(){
stopscroll=true;
}
Scroll.onmouseout=function(){
stopscroll=false;
}
xywInterval("ScrollInfo()",scrollDelay);
}
window.xywTimeout("Int_Scroll()",1000);
</script>
</body>
</html>
更多精彩
赞助商链接