js循环滚动

<DIV id=marquees>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tt" align="center" style="font-size:12px;font-family:Arial, Helvetica, sans-serif;">
  <tr>
   <td width="10" height="25">&nbsp;</td>
   <td width="234" class="linkz3"><div align="center" class="td_b">1111111111111111111111111</div></td>
   <td width="16">&nbsp;</td>
   <td width="225"><div align="center" class="td_b">1111111111111</div></td>
   <td width="223"><div align="center"><span class="td_b">111111111111111span></div></td>
   <td width="29">&nbsp;</td>
   <td width="276">
  <div align="center" class="td_b">
  111111111111111111
  </div>     
   </td>
   <td width="45">&nbsp;</td>
   <td width="190" class="td_b"><div align="center">1111111111</div></td>
   <td width="69">&nbsp;</td>
 </tr>
  </table>
</DIV>
<SCRIPT language=JavaScript>
stopscroll=false;
var marwidth=1002;
var marheight=260;
document.getElementById("marquees").style.width=marwidth;
document.getElementById("marquees").style.height=marheight;
document.getElementById("marquees").style.overflowX="hidden";
document.getElementById("marquees").style.overflowY="hidden";
document.getElementById("marquees").noWrap=false;
document.getElementById("marquees").onmouseover=new Function("stopscroll=true");
document.getElementById("marquees").onmouseout=new Function("stopscroll=false");
document.write("<div id='templayer' style='position:absolute;z-index:1;visibility:hidden;'></div>");
preTop=0;
currentTop=0;
function init(){
  templayer.innerHTML="";
  while(templayer.offsetHeight<marheight){
 templayer.innerHTML+=marquees.innerHTML;
  }
  marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
  setInterval("scrollUp()",20);//越大越慢
}
document.body.onload=init;
function scrollUp(){
  if(stopscroll==true) return;
  preTop=marquees.scrollTop;
  marquees.scrollTop+=1;
  if(preTop==marquees.scrollTop){
 marquees.scrollTop=templayer.offsetHeight-marheight;
 marquees.scrollTop+=1;
  }
}
</SCRIPT>

    A+
发布日期:2009年09月27日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: