<!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" />
 <meta http-equiv="Content-Language" content="GB2312" />
 <meta name="author" content="DSclub,兀儿-干部" />
 <meta name="Copyright" content="任兀" />
 <meta content="代码" name="keywords" />
    <title>文字滚动条</title>
 <style type="text/css" id="internalStyle">
 #gnomecons{border:1px solid #DDD; text-align: left; font: bold 12px serif; width: 200px; overflow:hidden;background: #FFF;}
 #gnomecons li{list-style-type: none;}
 </style>
  </head>
  <body>
 <table>
 <tr>
 <td>
    <div id="gnomecons">
 <li id="list1"></li>
 <li id="list2"></li>
 </div>
 </td>
 </tr>
 </table>
  </body>
</html>
<script language="JavaScript" type="text/javascript">
<!--

 /** 全局常量 **/
 var ListItem = 10; // 数组的长度
 var RunTimes = 30; // 动画以及停留的时间
 var xHeight = 30; // 显示的高度
 var xPadding = 5; // 补白
 

 var mycons = new Array();
 for( i = 0; i < ListItem; i++ )
 {
  mycons[i] = "数组" + i;
 }

 var icount = 0;  // 当前读取的数组下标
 var currentTips = 0;// 对scrollTop的限制
 var counttimes = 0; // 时间计数
 function ds_scrollH( obj ){
 currentTips++;
 if( currentTips == (xHeight - xPadding + 1) )
 {
  currentTips--;
  counttimes++;
  if( counttimes == RunTimes )
  {
   currentTips = 0;
   counttimes = 0;
   icount++;
   list1.innerText = mycons[icount];
   if(icount == ListItem - 1)
   {
    list2.innerText = mycons[0];
    icount = -1;
   }
   else
   {
    list2.innerText = mycons[icount+1];
   }
   obj.scrollTop = 0;

  }
 }
 else
 {
  obj.scrollTop += 1;
 }
 }
 gnomecons.style.height = xHeight + "px";
 list1.style.height = (xHeight - xPadding * 2) + "px";
 list1.style.lineHeight = (xHeight - xPadding * 2) + "px";
 list1.style.margin = xPadding + "px";
 list2.style.height = (xHeight - xPadding * 2) + "px";
 list2.style.lineHeight = (xHeight - xPadding * 2) + "px";
 list2.style.margin = xPadding + "px";
 // 初始化
 list1.innerText = mycons[0];
 list2.innerText = mycons[1];
 setInterval("ds_scrollH(gnomecons)", RunTimes);
//-->
</script>

posted on 2005-01-16 12:52  雪美·考拉  阅读(1013)  评论(1编辑  收藏  举报