1 <script language="javascript" type="text/javascript">
2 window.onload=function(){
3 var o=document.getElementById('box');
4 var o2=document.getElementById('box2');
5 window.setInterval(function(){scrollup(o,24,0);scrollup(o2,24,0)},3000)
6 }
7 ///滾動主方法
8 ///參數:o 滾動塊對象
9 ///參數:d 每次滾屏高度
10 ///參數:c 當前已滾動高度
11 function scrollup(o,d,c){
12 if(d==c){
13 var t=getFirstChild(o.firstChild).cloneNode(true);
14 o.removeChild(getFirstChild(o.firstChild));
15 o.appendChild(t);
16 t.style.marginTop="0px";
17 }else{
18 c+=2;
19 getFirstChild(o.firstChild).style.marginTop=-c+"px";
20 window.setTimeout(function(){scrollup(o,d,c)},20);
21 }
22 }
23 //解決firefox下會將空格回車作為節點的問題
24 function getFirstChild(node){
25 while (node.nodeType!=1)
26 {
27 node=node.nextSibling;
28 }
29 return node;
30 }
31 </script>