查看效果:向上滚动代码
<style>
div { font-size:12px; }
</style>
<div id=mq style=width:100%;height:70px;overflow:hidden onmouseover=iscrollamount=0
onmouseout=iscrollamount=1>
向上滚动代码 <br>
向上滚动代码<br>
向上滚动代码<br>
</div>
<script>
var omarquee = document.getelementbyid(mq); //滚动对象
var ilineheight = 42; //单行高度,像素
var ilinecount = 7; //实际行数
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>