关于javascript滚动文字脱节问题?

Justinfly 2009-05-20 08:49:53
下面是滚动文字的代码, 有3块DIV的文字,当滚到最后一个DIV 和第一DIV 间 会有空行,很难看。请教如何去除?

<html>
<head>

<title>滚动字幕类</title>
<style type="text/css">
*
{
font-size:12px;
}
#scrollBox
{
width:206px;
height:124px;
line-height:20px;
overflow:hidden;
background-color:#eee;
}

</style>
</head>
<body>
单行例子:(每屏一行)<br>
<br>
<hr style="height: 98%; border: 1px solid #A97716;" />
<div id="scrollBox" style="border: 1px solid #A97716; padding-left: 3px; padding-right: 3px">
<div>
山东于先生您的所购XXXX已经于<br>
5月17日通过圆通快递发出。<br>
运单号:122222222</div>
<div>
山东于先生您的所购XXXX已经于<br>
5月17日通过圆通快递发出。<br>
运单号:122222222</div>
<div>
辽宁张先生您的所购XXXX已经于<br>
4月21日通过圆通快递发出。<br>
运单号:122222222</div>
</div>

<script type="text/javascript">
function ScrollBox(uid)
{
this.scrollBox = document.getElementById(uid);
this.scrollBoxHeight = this.scrollBox.clientHeight;
this.scrollBoxInner = this.scrollBox.innerHTML;
this.scrollCol = this.scrolln = 0;
this.setScroll = function ()
{
this.scrollBox.scrollTop = this.scrollCol + this.scrolln;
if(this.scrolln==this.scrollBoxHeight)
return this.addScroll()
else
this.scrolln ++;
var o = this;
function m(){o.setScroll();}
setTimeout(m,20);
}
this.addScroll = function ()
{
this.scrollBox.innerHTML += "<br>" + this.scrollBoxInner;
this.scrollCol = this.scrollBox.scrollTop;
this.scrolln = 0;
var o = this;
function m(){o.setScroll();}
setTimeout(m,1000);
}
this.init = this.addScroll;
}
new ScrollBox("scrollBox").init();

</script>

</body>
</html>
...全文
60 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
caiying2009 2009-05-20
  • 打赏
  • 举报
回复
// this.scrollBox.innerHTML += " <br>" + this.scrollBoxInner;
this.scrollBox.innerHTML += this.scrollBoxInner;

87,993

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧