//外层div超出隐藏,内层div用js控制宽度,使里面的内容能浮左不换行 //延迟时间,li宽度,外层div宽度,内层div宽度,ul1的ID,ul2的ID*/ function ScrollFun(fn,yanchi,liWidth,divWidth,divW,divN,ul1Name,ul2Name) { this.speed=yanchi//速度数值越大速度越慢 var ulid2=document.getElementById(ul2Name); var ulid1=document.getElementById(ul1Name); var scrolldiv=document.getElementById(divW); var divNei=document.getElementById(divN); var isLong=false; var isCopy=true; scrolldiv.scrollLeft=0; this.GetSt=function () { divNei.style.width=ulid1.getElementsByTagName("li").length*liWidth*2+"px"; } this.GetSt(); if((ulid1.getElementsByTagName("li").length*liWidth)=sLeft) { scrolldiv.scrollLeft-=(ulid1.getElementsByTagName("li").length*liWidth); } else { scrolldiv.scrollLeft++ } } else { if(scrolldiv.scrollLeft==0) { scrolldiv.scrollLeft=(ulid1.getElementsByTagName("li").length*liWidth); } else { scrolldiv.scrollLeft-- } } } fn=setInterval(Marquee,this.speed) this.Stop=function(){clearInterval(fn);} this.Start=function(){fn=setInterval(Marquee,yanchi)} divNei.onmouseover=this.Stop; divNei.onmouseout=this.Start; } function ScrollFunDU(fn,tdsj,yanchi,liHeight,divHeight,divW,divN,ul1Name,ul2Name) { this.speed=yanchi//速度数值越大速度越慢 var ulid2=document.getElementById(ul2Name); var ulid1=document.getElementById(ul1Name); var scrolldiv=document.getElementById(divW); var divNei=document.getElementById(divN); var isLong=false; var isCopy=true; var nh=0; scrolldiv.scrollTop=0; this.GetSt=function () { nh=ulid1.getElementsByTagName("li").length; divNei.style.height=nh*liHeight*2+"px"; } this.GetSt(); var td=0; function Marquee() { if(nh<3) return; else isLong=true; if(isLong&&isCopy) { ulid2.innerHTML=ulid1.innerHTML; isCopy=false; } td++; var sTop=nh*liHeight*2-divHeight; if(scrolldiv.scrollTop>=sTop) { var py=(nh*liHeight); scrolldiv.scrollTop-=py; scrolldiv.scrollTop++; } else { scrolldiv.scrollTop++; } if(td==(liHeight)) { clearInterval(fn); fn=setTimeout(function(){fn=setInterval(Marquee,this.speed)},tdsj); td=0; return ; } } fn=setInterval(Marquee,this.speed) this.Stop=function(){clearInterval(fn); clearTimeout(fn);} this.Start=function(){fn=setInterval(Marquee,yanchi)} divNei.onmouseover=this.Stop; divNei.onmouseout=this.Start; }