为什么我这段JS图片滚动的代码滚动一会就停了。能不能让它循环滚动啊。
<divid="jsweb8_cn_left"style="overflow:hidden;width:830px;margin-top:12px;float:left;...
<div id="jsweb8_cn_left" style="overflow:hidden;width:830px; margin-top:12px; float:left;">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="jsweb8_cn_left1" valign="top" align="center">
<table cellpadding="5" cellspacing="5" border="0">
<tr align="center">
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" ></a> </td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"> </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"> </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
</tr>
</table>
</td>
<td id="jsweb8_cn_left2" valign="top"></td>
</tr>
</table>
</div>
<!--向左滚动代码结束-->
</div>
<script type="text/javascript">
var speed=30//速度数值越大速度越慢
//alert(document.getElementById('jsweb8_cn_left1').innerHTML);
document.getElementById('jsweb8_cn_left2').innerHTML=document.getElementById('jsweb8_cn_left1').innerHTML
function Marquee3(){
if(document.getElementById('jsweb8_cn_left2').offsetWidth-document.getElementById('jsweb8_cn_left').scrollLeft<=0)
document.getElementById('jsweb8_cn_left').scrollLeft-=document.getElementById('jsweb8_cn_left1').offsetWidth
else{
document.getElementById('jsweb8_cn_left').scrollLeft++
}
}
var MyMar3=setInterval(Marquee3,speed)
document.getElementById('jsweb8_cn_left').onmouseover=function() {clearInterval(MyMar3)}
document.getElementById('jsweb8_cn_left').onmouseout=function() {MyMar3=setInterval(Marquee3,speed)}
</script>
</div> 展开
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="jsweb8_cn_left1" valign="top" align="center">
<table cellpadding="5" cellspacing="5" border="0">
<tr align="center">
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" ></a> </td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90" > </a></td>
<td class="pich" width="147" height="90" ><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"> </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"> </a></td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
<td class="pich" width="147" height="90"><a href="#"><img src="images/cp.jpg" border="0" width="147" height="90"></a> </td>
</tr>
</table>
</td>
<td id="jsweb8_cn_left2" valign="top"></td>
</tr>
</table>
</div>
<!--向左滚动代码结束-->
</div>
<script type="text/javascript">
var speed=30//速度数值越大速度越慢
//alert(document.getElementById('jsweb8_cn_left1').innerHTML);
document.getElementById('jsweb8_cn_left2').innerHTML=document.getElementById('jsweb8_cn_left1').innerHTML
function Marquee3(){
if(document.getElementById('jsweb8_cn_left2').offsetWidth-document.getElementById('jsweb8_cn_left').scrollLeft<=0)
document.getElementById('jsweb8_cn_left').scrollLeft-=document.getElementById('jsweb8_cn_left1').offsetWidth
else{
document.getElementById('jsweb8_cn_left').scrollLeft++
}
}
var MyMar3=setInterval(Marquee3,speed)
document.getElementById('jsweb8_cn_left').onmouseover=function() {clearInterval(MyMar3)}
document.getElementById('jsweb8_cn_left').onmouseout=function() {MyMar3=setInterval(Marquee3,speed)}
</script>
</div> 展开
展开全部
<!--下面是向左滚动代码-->
<div id="colee_left" style="overflow:hidden;width:500px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="colee_left1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0">
<tr align="center">
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
</tr>
</table>
</td>
<td id="colee_left2" valign="top"></td>
</tr>
</table>
</div>
<script>
//使用div时,请保证colee_left2与colee_left1是在同一行上.
var speed=30//速度数值越大速度越慢
var colee_left2=document.getElementById("colee_left2");
var colee_left1=document.getElementById("colee_left1");
var colee_left=document.getElementById("colee_left");
colee_left2.innerHTML=colee_left1.innerHTML
function Marquee3(){
if(colee_left2.offsetWidth-colee_left.scrollLeft<=0)//offsetWidth 是对象的可见宽度
colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth 是对象的实际内容的宽,不包边线宽度
else{
colee_left.scrollLeft++
}
}
var MyMar3=setInterval(Marquee3,speed)
colee_left.onmouseover=function() {clearInterval(MyMar3)}
colee_left.onmouseout=function() {MyMar3=setInterval(Marquee3,speed)}
</script>
<!--向左滚动代码结束--> 你试试这个 我一直用的
<div id="colee_left" style="overflow:hidden;width:500px;">
<table cellpadding="0" cellspacing="0" border="0">
<tr><td id="colee_left1" valign="top" align="center">
<table cellpadding="2" cellspacing="0" border="0">
<tr align="center">
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
<td><p><img src="http://www.alixixi.com/images/noimg.gif"></p></td>
</tr>
</table>
</td>
<td id="colee_left2" valign="top"></td>
</tr>
</table>
</div>
<script>
//使用div时,请保证colee_left2与colee_left1是在同一行上.
var speed=30//速度数值越大速度越慢
var colee_left2=document.getElementById("colee_left2");
var colee_left1=document.getElementById("colee_left1");
var colee_left=document.getElementById("colee_left");
colee_left2.innerHTML=colee_left1.innerHTML
function Marquee3(){
if(colee_left2.offsetWidth-colee_left.scrollLeft<=0)//offsetWidth 是对象的可见宽度
colee_left.scrollLeft-=colee_left1.offsetWidth//scrollWidth 是对象的实际内容的宽,不包边线宽度
else{
colee_left.scrollLeft++
}
}
var MyMar3=setInterval(Marquee3,speed)
colee_left.onmouseover=function() {clearInterval(MyMar3)}
colee_left.onmouseout=function() {MyMar3=setInterval(Marquee3,speed)}
</script>
<!--向左滚动代码结束--> 你试试这个 我一直用的
更多追问追答
追问
跟我的一样。静态好用。但是加完后台后。就执行一遍就停了。应该是没等所有图片加载完就执行JS了。所以就不循环了。
追答
那是因为图片的数量没有达到 多加几张图片 就可以一直循环了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询