html 滾動

assureo發表於2007-12-25

<script language="JavaScript">

marqueesHeight=200;
stopscroll=false;

with(marquees){
   style.width=0;
   style.height=marqueesHeight;
   style.overflowX="visible";
 //   style.overflowY="hidden";
   style.overflowY="auto";
   noWrap=true;
   onmouseover=new Function("stopscroll=true");
   onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');

preTop=0; currentTop=0;

function init(){
   templayer.innerHTML= "";
   while(templayer.offsetHeight<marqueesHeight){
     templayer.innerHTML+=marquees.innerHTML;
   }
   marquees.innerHTML=templayer.innerHTML;
   setInterval("scrollUp()",100);
}
document.body.onload=init;

function scrollUp(){
   if(stopscroll==true) return;
   preTop=marquees.scrollTop;
   marquees.scrollTop+=1;
   if(preTop==marquees.scrollTop){
     //marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
     //marquees.scrollTop+=1;
     marquees.scrollTop=0;
   }
}
</script>  

相關文章