WEB开发网
开发学院网页设计JavaScript js数据向上翻滚_数据滚动 阅读

js数据向上翻滚_数据滚动

 2010-09-14 13:28:25 来源:WEB开发网   
核心提示:<script type="text/javascript">var scrollDelay=10;//数字越大速度越慢var Scroll=document.getElementById("scroll");var Scroll2=document.getEleme

<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;
}
setInterval("ScrollInfo()",scrollDelay);
}
window.setTimeout("Int_Scroll()",1000);
</script>

运行可以看到效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Untitled</title>
  <style type="text/css">
    .kefuchu{ width:109px;}
    .SS_dh1{background:url(../images/SSindex/SS_dh1.jpg) no-repeat; height:51px; width:84px; float:left}
    .SS_dh2{background:url(../images/SSindex/SS_dh2.jpg) no-repeat; height:51px; width:25px; float:left; display:block}
    .SS_dh3{background:url(../images/SSindex/SS_dh3.jpg) repeat-y; width:109px; }
    .SS_dh4{background:url(../images/SSindex/SS_dh4.jpg) no-repeat; height:17px; width:109px; }
    .SS_dh5{background:url(../images/SSindex/SS_dh5.jpg) no-repeat; height:23px; width:74px; margin-left:20px;}
    
    
    #scroll li{float:left;width:150px;}
    #scroll2{display:none;}
  </style>
</head>

1 2  下一页

Tags:js 数据 向上

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接