<div id="mq" style="width:100%;height:18px;overflow:hidden;border:1px solid #ffffff" onmouseout="iScrollAmount=1">
轻轻的我走了,正如我轻轻的来;<br/>
我轻轻的招手,作别西天的云彩。<br/>
那河畔的金柳,是夕阳中的新娘;<br/>
波光里的艳影,在我心头荡漾。 <br>
</div>
<script>
var oMarquee = document.getElementById("mq"); //滚动对象
var iLineHeight = 16; //单行高度,像素
var iLineCount = 4; //实际行数
var iScrollAmount = 1; //每次滚动高度,像素
function run() {
oMarquee.scrollTop += iScrollAmount;
if ( oMarquee.scrollTop == iLineCount * iLineHeight )
oMarquee.scrollTop = 0;
if ( oMarquee.scrollTop % iLineHeight == 0 ) {
window.setTimeout( "run()", 2000 );
} else {
window.setTimeout( "run()", 50 );
}
}
oMarquee.innerHTML += oMarquee.innerHTML;
window.setTimeout( "run()", 2000 );
</script>
原文地址:http://jyb2014.blog.51cto.com/9155315/1559708