循環不間斷向上滾動的文本特效代碼,可以當作網站公告也可以調整文字滾動的速度,還可以實現鼠標放上面停止滾動,鼠標離開又繼續滾動。
<Html> <head> <title>不間斷循環向上滾動的文本特效</title> </head> <body> <div id="marquees"> <a href="#">*knowsky.com歡迎您1</a><br> <br> <a href="#">*knowsky.com歡迎您2</a><br> <br> <a href="#">*knowsky.com歡迎您3</a><br> <br> <a href="#">*knowsky.com歡迎您4</a><br> <br> </div> <script language="JavaScript"> marqueesHeight=200; stopscroll=false; with(marquees){ style.width=0; style.height=marqueesHeight; style.overflowX="visible"; style.overflowY="hidden"; noWrap=true; onmouseover=new Function("stopscroll=true"); 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<marqueesHeight){ templayer.innerHTML+=marquees.innerHTML; } marquees.innerHTML=templayer.innerHTML+templayer.innerHtml; setInterval("scrollUp()",10); } document.body.onload=init; function scrollUp(){ if(stopscroll==true) return; preTop=marquees.scrollTop; marquees.scrollTop+=1; if(preTop==marquees.scrollTop){ marquees.scrollTop=templayer.offsetHeight-marqueesHeight; marquees.scrollTop+=1; } } </script>