我有一個垂直滾動腳本,對我來說很好,但問題是它會在一段時間後停下來。如何修改腳本,以便它可以一次又一次地從頭到尾無限滾動?
下面是代碼:無限垂直滾動條
<html>
<head>
<style type="text/css">
.frame {
font:12px arial;
width:200;
height:300;
border:none;
overflow: hidden;
border:1px solid black;
padding:5;
}
</style>
<script language="javascript">
i = 0
var speed = 1
function scroll() {
i = i + speed
var div = document.getElementById("news")
div.scrollTop = i
if (i > div.scrollHeight - 160) {i = 0}
t1=setTimeout("scroll()",100)
}
</script>
</head>
<body onload="scroll()">
<div class="frame" id="news" onmouseover="clearTimeout(t1)" onmouseout="scroll()" >
Some Text text 1<br>
Some Text text 2<br>
Some Text text 3<br>
Some Text text 4<br>
Some Text text 5<br>
Some Text text 6<br>
Some Text text 7<br>
Some Text text 8<br>
Some Text text 9<br>
Some Text text 10<br>
Some Text text 11<br>
Some Text text 12<br>
Some Text text 13<br>
Some Text text 14<br>
Some Text text 15<br>
Some Text text 16<br>
Some Text text 17<br>
Some Text text 18<br>
Some Text text 19<br>
Some Text text 20<br>
Some Text text 21<br>
</div>
</body>
</html>
你想說什麼的JavaScript控制檯何時停止工作? – Oded