js文本滚动播出
2014 年 11 月 5 日 at 下午 4:24分类:Other
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <style> #scroll {width:280px;height:88px;font-size:12px; line-height:22px;overflow:hidden}; </style> <ul> <div id="scroll" onmouseover="iScrollAmount=0" onmouseout="iScrollAmount=1" > <li>1111</li> <li>2222</li> <li>3333</li> <li>4444</li> <li>5555</li> <li>6666</li> <li>7777</li> <li>8888</li> <li>9999</li> <li>2121</li> <li>1212</li> <li>1313</li> </div> </ul> <script> var oMarquee = document.getElementById("scroll"); //滚动对象 var iLineHeight = 440; //单行高度,像素 var iLineCount = 12; //实际行数 var iScrollAmount = 1; //每次滚动高度,像素 function run() { oMarquee.scrollTop += iScrollAmount; if ( oMarquee.scrollTop == iLineCount * iLineHeight ) { oMarquee.scrollTop = 0; } if ( oMarquee.scrollTop % iLineHeight == 0 ) { oMarquee.scrollTop = 0; } window.setTimeout( "run()", 50 ); } oMarquee.innerHTML += oMarquee.innerHTML; window.setTimeout( "run()", 2000 ); </script> |