<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>runLight</title>
<script type="text/javascript">
var msg="这是一个跑马灯的效果";
var interval = 500;
var spacelen = 120;
var space10 = " ";
var seq = 0;
var len = msg.length;
function Go(){
if (seq>=len){
//seq=spacelen;
//alert(seq)
setInterval("Scroll2()",interval);
}else{
//alert(seq)
setInterval("Scroll()",interval);
}
};
function Scroll(){
//alert(msg)
//window.status=msg.substring(0,seq+1);
document.title = msg.substring(0,seq+1);
seq++;
if (seq>=len){Scroll2()};
};
function Scroll2(){
var out="";
for (i =1;i<=spacelen/space10.length;i++);
out+=space10;
out=out+msg;
len = out.length;
document.title = out.substring(seq,len);
seq++;
//if(seq>=len){seq=0};
//window.setTimeout(Scroll(),interval);
};
window.onload = Go;
//alert(Scroll2());
//Scroll();
</script>
</head>
<body>
<input type="button" value="test" onclick="Scroll()"/>
</body>
</html>
修改了半天也不对,现在如果重复点击button可以让标题文字循环,怎么样才能让它自动跑起来?
xieyao。首先,看不懂题主写的什么。。。自己大致写一下