问题描述
公告栏里的公告列表向上滚动,是无间隔循环向上滚动的,不知道JS是怎么写的,谁有完整的例子吗, 谢谢大家.
解决方案
解决方案二:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/><title>无标题文档</title></head><body><divid="Div1"style="overflow:hidden;width:128px;height:100px;"><divid="Div2">a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>bccd</div><divid="Div3"></div></div><scriptlanguage="javascript">varspeed=30Div3.innerHTML=Div2.innerHTMLfunctionMarquee(){if(Div3.offsetTop-Div1.scrollTop<=0)Div1.scrollTop-=Div2.offsetHeightelse{Div1.scrollTop++}}varMyMar=setInterval(Marquee,speed)Div1.onmouseover=function(){clearInterval(MyMar)}Div1.onmouseout=function(){MyMar=setInterval(Marquee,speed)}</script></body></html>把上面的代码保存成一个网页,运行试试!~~~~无缝隙,自动循环!~~~
解决方案三:
<style>a{display:block;font-size:15px};</style><divid="div1"style="width:300px;height:68px;overflow:hidden"><ahref="javascript:">1,你可曾有过无数的梦想,</a><ahref="javascript:">2,却在时光的流逝里幻灭</a><ahref="javascript:">3,你可曾对未来期待憧憬,</a><ahref="javascript:">4,却在成长的岁月中迷失</a><ahref="javascript:">5,CSDN中国程序员论坛</a><ahref="javascript:">6,大家一起来</a><ahref="javascript:">7,好象都很不错的样子</a></div><script>vart=setInterval(myfunc,1000)vard=document.getElementById("div1")functionmyfunc(){varo=d.firstChildd.removeChild(o)d.appendChild(o)}d.onmouseover=function(){clearInterval(t)}d.onmouseout=function(){t=setInterval(myfunc,1000)}</script>2,<divid="marquees"><ahref="#">链接一</a><br><br><ahref="#">链接二</a><br><br><ahref="#">链接三</a><br><br><ahref="#">链接四</a><br><br></div><scriptlanguage="JavaScript">marqueesHeight=200;stopscroll=false;with(marquees){style.width=0;style.height=marqueesHeight;style.overflowX="visible";style.overflowY="hidden";noWrap=true;onmouseover=newFunction("stopscroll=true");onmouseout=newFunction("stopscroll=false");}document.write('<divid="templayer"style="position:absolute;z-index:1;visibility:hidden"></div>');preTop=0;currentTop=0;functioninit(){templayer.innerHTML="";while(templayer.offsetHeight<marqueesHeight){templayer.innerHTML+=marquees.innerHTML;}marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;setInterval("scrollUp()",10);}document.body.onload=init;functionscrollUp(){if(stopscroll==true)return;preTop=marquees.scrollTop;marquees.scrollTop+=1;if(preTop==marquees.scrollTop){marquees.scrollTop=templayer.offsetHeight-marqueesHeight;marquees.scrollTop+=1;}}</script>
解决方案四:
解决方案五:
楼上的可以的试试吧