文字不间断向上滚动

<style type="text/css">
#rollAD{height:20px; position:relative; overflow:hidden; font-size:12px; line-height:20px; background-color:#CCCCCC; width:440px }
#rollAD li { float:left; width:170px; overflow:hidden}
</style>
<div id="rollAD" >
  <div id="rollText">
    <li><a href="#">安理会改革拟新增七理事国1</a></li>
    <li>安理会改革拟新增七理事国2</li>
    <li>安理会改革拟新增七理事国3</li>
    <li>安理会改革拟新增七理事国4</li>
  </div>
</div>
<script type="text/javascript">
var textDiv = document.getElementById("rollText");
 var textDat = textDiv.innerHTML;
 textDiv.innerHTML = textDat+textDat;
 textDiv.style.cssText = "position:absolute; top:0";
 var textDatH = textDiv.offsetHeight;MaxRoll();
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
 newTop++;
 if(newTop<=divTop+20){
  textDiv.style.top = "-" + newTop + "px";
 }else{
  clearInterval(minTime);
  maxTime = setTimeout(MaxRoll,5000);
 }
}
function MaxRoll(){
 divTop = Math.abs(parseInt(textDiv.style.top));
 if(divTop>=0  &&  divTop<textDatH-20){
  minTime = setInterval(MinRoll,1);
 }else{
  textDiv.style.top = 0;divTop = 0;newTop=0;MaxRoll();
 }
}
</script>
posted @ 2009-02-11 17:13  郑希强  阅读(1182)  评论(0编辑  收藏  举报