有关气象的谚语:html滚动文本框

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/03 19:52:49
我在作滚动文本框时,当文本滚动时,当最后一行滚动出文本框时才开始下一次,这样,中间会有一段时间有一大片空白,怎么才能使最后一行刚开始出现在文本框时,第一行马上接着就开始滚动实现这样的循环

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>连续向左滚动</title>
<style type="text/css">
<!--
body {font-size: 9pt;color: #000000;}
a {color: #0000FF;text-decoration: none;}
a:hover {color: #FF0000;text-decoration: underline;}
-->
</style>
</head>
<body>
<div id="marquees">
天使之城,呀呀!嘿!飞洒发萨地方萨贩毒阿开工;拉萨交流;个了;阿哥
</div>

<div id="templayer" style="position:absolute;left:0;top:0;visibility:hidden"></div>
<script language="JavaScript">
marqueesWidth=200;
with(marquees){
style.height=0;
style.width=marqueesWidth;
style.overflowX="hidden";
style.overflowY="visible";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
preLeft=0; currentLeft=0; stopscroll=false;

function init(){
templayer.innerHTML="";
while(templayer.offsetWidth<marqueesWidth){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML+=templayer.innerHTML;
setInterval("scrollLeft()",10);
}init();

function scrollLeft(){
if(stopscroll==true) return;
preLeft=marquees.scrollLeft;
marquees.scrollLeft+=1;
if(preLeft==marquees.scrollLeft){
marquees.scrollLeft=templayer.offsetWidth-marqueesWidth+1;
}
}
</script>
</body>
</html>
给你个例子,看看就明白了