再次您好,我发现了一个很棒的脚本,它几乎可以完成我想要的问题是当页面加载时它不会自行移动我们可以更改它来做到这一点吗?我的想法是让消息向下滚动,我想让它形成一个循环,这样我就有一条消息,它会从上到下移动,但它永远不会像选框一样停止移动,提前谢谢!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
scrollStep=1
timerUp=""
timerDown=""
function toTop(id){
document.getElementById(id).scrollTop=0
}
function scrollDivDown(id){
clearTimeout(timerDown)
document.getElementById(id).scrollTop+=scrollStep
timerDown=setTimeout("scrollDivDown('"+id+"')",10)
}
function scrollDivUp(id){
clearTimeout(timerUp)
document.getElementById(id).scrollTop-=scrollStep
timerUp=setTimeout("scrollDivUp('"+id+"')",10)
}
function toBottom(id){
document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight
}
function stopMe(){
clearTimeout(timerDown)
clearTimeout(timerUp)
}
</script>
<style>
#display{
width:200px;
height:150px;
overflow:hidden;
text-align:left;
border:1px solid black;
}
</style>
</head>
<body>
<a href="#null" onclick="toTop('display')">Top</a>
<a href="#null" onmouseover="scrollDivDown('display')" onmouseout="stopMe()">ScrollDown</a>
<a href="#null" onmouseover="scrollDivUp('display')" onmouseout="stopMe()">Scroll Up</a>
<a href="#null" onclick="toBottom('display')">Bottom</a>
<div id="display">
<b>LAYER CONTENTS</b>
<P>Dummy Text<P>Dummy Text<P>Dummy Text<P>Dummy Text
<P>Dummy Text<P>Dummy Text<P>Dummy Text<P>Dummy Text
<P>Dummy Text<P>Dummy Text<P>Dummy Text<P>Dummy Text
<P>Dummy Text<P>Dummy Text<P>Dummy Text<P>End
</div>
</body>
</html>
我想做这样的事情,所以它会循环:
function scrollDown(id){
clearTimeout(timerDown)
document.getElementById(id).scrollTop+=scrollStep
if (document.getElementById(id).scrollTop=document.getElementById(id).scrollHeight){
document.getElementById(id).scrollTop=0
}
}
<div id="display" onmouseout="scrollDown('display')" onmouseover="stopMe()">
在这个 div 下它的消息