background image
bottomlabel.innerHTML=toplabel.innerHTML;//复制 top 内容到 bottom,用来循环滚动
显示
function move()
{
//当 top 滚动值 scrollTop+offsetHeight 等于 top div 的 scrollHeight 时。t
opdiv 停止滚动,并减少 top div 的 style.height 值
if ((toplabel.scrollTop+toplabel.offsetHeight)>=toplabel.scrollHeig
ht)
{
toplabel.style.height=height-=speed;
bottomlabel.style.height=bottomheight+=speed;
//减少 top heigth 并同步增加 bottom height,这样,可以实现无缝滚动。
if (height<MIN_HEIGHT){
//top height 值减少到 0 时,停止递减过程,并使 top 的 scrollTop 值等于 bottom 的 offsetTop。
toplabel.scrollTop=bottomlabel.offsetTop;
toplabel.style.height=height=MAX_HEIGHT;
bottomlabel.style.height=bottomheight=MIN_HEIGHT;
//同时再改变 top 和 bottom 的 height 的值,然后继续递增 top 的 scrollTop,实现滚动。
}
}
toplabel.scrollTop+=speed;
t=setTimeout(move,100);
//定义计时器,并递增 top scrollTop。
}
//启动和鼠标进入,离开执行函数。实现鼠标移动上去停止滚动,离开继续滚动
move();
function stop()
{
clearTimeout(t);
}
function start()
{
t=setTimeout(move,100);
}
</script>
</body>
</html>