日期:2014-05-16  浏览次数:20408 次

这是一个文字向上滚动的例子,请问如何改成向下滚动?
这是一个文字向上滚动的例子,请问如何改成向下滚动?
HTML code

<!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> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <title>文字向上滚动</title> 
  <style type="text/css"> 
   .box{width:500px; height:150px;line-height:25px; border:#bbb 1px solid; overflow:hidden;} 
   .box ul{margin:0; padding:0} 
   .box li{font-size:12px; } 
  </style> 
</head> 

<body> 
    <div class="box" id="marqueebox0"> 
            <ul>
                <li>11111111</li>
                <li>22222222</li>
                <li>33333333</li>
                <li>44444444</li>
                <li>55555555</li>
                <li>66666666</li>
            </ul>
    </div>
 

    <script type="text/javascript"> 
        function startmarquee(lh,speed,delay,index){ 
            var t; 
            var p=false; 
            var o=document.getElementById("marqueebox"+index); 
            o.innerHTML+=o.innerHTML; 
            o.onmouseover=function(){p=true} 
            o.onmouseout=function(){p=false} 
            o.scrollTop = 0; 
            
            function start(){ 
                t=setInterval(scrolling,speed); 
                if(!p){ o.scrollTop += 1;} 
            } 
            
            function scrolling(){ 
                if(o.scrollTop%lh!=0){ 
                o.scrollTop += 1; 
                if(o.scrollTop>=o.scrollHeight/2) o.scrollTop = 0; 
                }else{ 
                    clearInterval(t); 
                    setTimeout(start,delay); 
                } 
            } 
            setTimeout(start,delay); 
        } 
startmarquee(50,30,3000,0); 

</script> 
</body> 
</html> 



------解决方案--------------------
改好了:

HTML code

<!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> 
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
  <title>文字向上滚动</title> 
  <style type="text/css"> 
   .box{width:500px; height:150px;line-height:25px; border:#bbb 1px solid; overflow:hidden;} 
   .box ul{margin:0; padding:0} 
   .box li{font-size:12px; } 
  </style> 
</head> 

<body> 
    <div class="box" id="marqueebox0"> 
            <ul>
                <li>11111111</li>
                <li>22222222</li>
                <li>33333333</li>
                <li>44444444</li>
                <li>55555555</li>
                <li>66666666</li>
            </ul>
    </div>
 
<input value = "1" id="tt">
<input value = "1" id="tt2">
    <script type="text/javascript"> 
        function startmarquee(lh,speed,delay,index){ 
            var t; 
            var p=false; 
            var o=document.getElementById("marqueebox"+index); 
            o.innerHTML+=o.innerHTML; 
            o.onmouseover=function(){p=true} 
            o.onmouseout=function(){p=false} 
            o.scrollTop = o.scrollHeight;
            
            function start(){ 
                t=setInterval(scrolling,speed); 
                if(!p)