求一段滚动显示的js代码

来源:百度知道 编辑:UC知道 时间:2024/05/11 03:18:34
比如说我有9行字
每次显示3行 停顿1秒后 往上滚动 再显示4.5.6三行 再停顿 再滚动显示7.8.9 现在的问题是 显示完4.5.6后滚动到7.8.9的时候 他会滚动到一半 又显示1.2.3行了 7.8.9的时间不够
<script type="text/javascript">
<!--
var marqueesHeight=60;
var stopscroll=false;
var scrollElem = document.getElementById("scrollTable");
with(scrollElem){
style.width = 200;
style.height = marqueesHeight;
style.overflow = "hidden";
noWrap = true;
//onmouseover=new Function("stopscroll=true");
//onmouseout=new Function("stopscroll=false");
}

scrollElem.onmouseover=new Function("stopscroll=true");
scrollElem.onmouseout=new Function("stopscroll=false");

var preTop=0;
var currentTop=marqueesHeight;
var stoptime=0;
initSrollText();

function initSrollText(){
scrollElem.scrollTop=0;
setInterval("scrollUp()",20);
}

给你一个实现类似功能的代码

<style type="text/css">
#infozone{font-size:12px;color:#aa6;overflow:hidden;width:800px;height:60px;} <!--这里修改Div高度 -->
#infozone div{height:60px;line-height:20px;white-space:nowrap;overflow:hidden;} <!--这里修改Div高度 -->
</style>
<div id="infozone">
<div>第1行:醉迷情人<br>第2行:路边野花不要采<br>第3行:海的女儿</div>
<div>第4行:醉迷情人<br>第5行:路边野花不要采<br>第6行:海的女儿</div>
<div>第7行:醉迷情人<br>第8行:路边野花不要采<br>第9行:海的女儿</div>
</div>
<script type="text/javascript">
var o=document.getElementById('infozone');
mr=window.setInterval(function(){scrollup(o,60,0);},4000); //4000代表间隔多长时间,包括滚动的时间。60代表滚动的高度。
infozone.onmouseover=function() {clearInterval(mr)}
infozone.onmouseout=function() {mr=setInterval(function(){scrollup(o,60,0);},4000)} //同上
function scrollup(o,d,c){
if(d<=c){