复制代码 代码如下: function startmarquee(lh,speed,delay,index){ var o=document.getElementById("demo"+index); var o_td=o.getElementsByTagName("td")[0]; var str=o_td.innerHTML; var newtd=document.createElement("td"); newtd.innerHTML=str; o_td.parentNode.appendChild(newtd); var t; var p=false; o.onmouseover=function(){p=true;} o.onmouseout=function() {p=false;} function start(){ t=setInterval(Marquee,speed); if(!p){o.scrollLeft += 3;} } function Marquee(){ if(o_td.offsetWidth-o.scrollLeft<=0) o.scrollLeft-=o_td.offsetWidth; else{ if(o.scrollLeft%lh!=0){ o.scrollLeft+= 3 }else{clearInterval(t); setTimeout(start,delay);} } } setTimeout(start,delay); } startmarquee(102,1,1500,1);//图片间停式滚动 startmarquee(102,30,1,2);//图片不间断滚动