日期:2014-05-16  浏览次数:20501 次

图片上下滚动无缝隙效果的问题
现在滚动一次就停了,要如果设置让他不停
HTML code
<div id=demo style="overflow:hidden; width:128px; height:300px;"> 
<div id=demo1> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
<img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br> 
</div> 
<div id=demo2></div> 
</div> 
<script language="javascript"> 
var speed=30 
demo2.innerHTML=demo1.innerHTML 
function Marquee(){ 
if(demo2.offsetTop-demo.scrollTop<=0) 
demo.scrollTop-=demo1.offsetHeight 
else{ 
demo.scrollTop++ 
} 
} 
var MyMar=setInterval(Marquee,speed) 
demo.onmouseover=function() {clearInterval(MyMar)} 
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} 
</script> 


------解决方案--------------------
都使用
document.getElementById("demo1")获得对象,而不是直接demo1
其他类似

其他测试没有问题



<div id=demo style="overflow:hidden; width:128px; height:300px;"> 
<div id=demo1> 
<img src="http://dotnet.aspx.cc/Images/logoSite.gif"><br><img src="http://dotnet.aspx.cc/Images/qrcode.png"><br><img 

src="http://dotnet.aspx.cc/Images/logoSite.gif"><br> 
<img src="http://dotnet.aspx.cc/Images/logoSite.gif"><br><img src="http://dotnet.aspx.cc/Images/qrcode.png"><br><img 

src="http://dotnet.aspx.cc/Images/logoSite.gif"><br> 
<img src="http://dotnet.aspx.cc/Images/logoSite.gif"><br><img src="http://dotnet.aspx.cc/Images/qrcode.png"><br><img 

src="http://dotnet.aspx.cc/Images/logoSite.gif"><br> 
<img src="http://dotnet.aspx.cc/Images/logoSite.gif"><br><img src="http://dotnet.aspx.cc/Images/qrcode.png"><br><img 

src="http://dotnet.aspx.cc/Images/logoSite.gif"><br> 
<img src="http://dotnet.aspx.cc/Images/logoSite.gif"><br><img src="http://dotnet.aspx.cc/Images/qrcode.png"><br><img 

src="http://dotnet.aspx.cc/Images/logoSite.gif"><br> 
<img src="http://dotnet.aspx.cc/Images/logo