连续滚动

来源:互联网 发布:mac os使用教程 2017 编辑:程序博客网 时间:2024/04/30 09:41

<html>

<head>

<title></title>
<style type="text/css">
      li{
         height : 25px;
   list-style:none;
         }
</style>
<script language="javascript">
   var scrollPane=null;
   var container=null;
   var scrollPane2=null;
   var i=0;
   function init()
   {
       scrollPane=document.getElementById("scrollPane");
       container=document.getElementById("container");
    load();
   }
   function load()
   {  
      var parent=scrollPane.parentNode;
   scrollPane2=document.createElement("div");
   scrollPane2.innerHTML=scrollPane.innerHTML;
   parent.appendChild(scrollPane2);
   scroll();
   }
   function scroll()
   {
      
       if(scrollPane2.offsetTop-container.scrollTop<=0)
    {
           container.scrollTop-=scrollPane.offsetHeight;
       }
    if(i%50<25)
    {
        container.scrollTop++;
    }
    i++;
       window.setTimeout("scroll()",100);
         
   }
  
   function debug(str)
   {
       document.body.insertAdjacentHTML("BeforeEnd",str+"<br>");
   }
   window.onload=init;
</script>
</head>

<body>
<div style="overflow-y:hidden; height:25px; border:1px solid #EEEEEE; width:300px;" id="container">
    <div id="scrollPane">
      <li>test 1 line in this pane</li>
      <li>test 2 line in this pane</li>
      <li>test 3 line in this pane</li>
    </div>
</div>
</body>
</html>