请高手帮看下下面图片滚动的js代码有什么问题
在我的电脑上滚了10秒左右就停止了!真郁闷代码如下:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""ht...
在我的电脑上滚了10秒左右就停止了! 真郁闷
代码如下:
<!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=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:950px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr><td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr></table>
</td><td id=marquePic2 valign=top></td></tr>
</table></div>
<script type="text/javascript">
var speed=18
marquePic2.innerHTML=marquePic1.innerHTML
function Marquee(){
if(show.scrollLeft>=marquePic1.scrollWidth){
show.scrollLeft=0
}else{
show.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
show.onmouseover=function() {clearInterval(MyMar)}
show.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html> 展开
代码如下:
<!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=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:950px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr><td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr></table>
</td><td id=marquePic2 valign=top></td></tr>
</table></div>
<script type="text/javascript">
var speed=18
marquePic2.innerHTML=marquePic1.innerHTML
function Marquee(){
if(show.scrollLeft>=marquePic1.scrollWidth){
show.scrollLeft=0
}else{
show.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
show.onmouseover=function() {clearInterval(MyMar)}
show.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html> 展开
2个回答
展开全部
<!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=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:948px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr>
<td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr>
</table>
</td>
<td id=marquePic2 valign=top></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed = 1;
var show = document.getElementById("show");
var marquePic1 = document.getElementById("marquePic1");
var marquePic2 = document.getElementById("marquePic2");
marquePic2.innerHTML = marquePic1.innerHTML;
function Marquee() {
if (show.scrollLeft >= marquePic1.scrollWidth) {
show.scrollLeft = 0;
} else {
show.scrollLeft++;
}
}
var MyMar = setInterval(Marquee,speed);
show.onmouseover = function() { clearInterval(MyMar) }
show.onmouseout = function() { MyMar = setInterval(Marquee,speed) }
</script>
</body>
</html>
回答:你的代码并没有错的,你的id="show"显示区域width过大,导致(show.scrollLeft >= marquePic1.scrollWidth)不成立,你可以多增加一个TD或者减少id="show"的宽度看看效果,可以循环的,我帮你优化了代码。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:948px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr>
<td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr>
</table>
</td>
<td id=marquePic2 valign=top></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed = 1;
var show = document.getElementById("show");
var marquePic1 = document.getElementById("marquePic1");
var marquePic2 = document.getElementById("marquePic2");
marquePic2.innerHTML = marquePic1.innerHTML;
function Marquee() {
if (show.scrollLeft >= marquePic1.scrollWidth) {
show.scrollLeft = 0;
} else {
show.scrollLeft++;
}
}
var MyMar = setInterval(Marquee,speed);
show.onmouseover = function() { clearInterval(MyMar) }
show.onmouseout = function() { MyMar = setInterval(Marquee,speed) }
</script>
</body>
</html>
回答:你的代码并没有错的,你的id="show"显示区域width过大,导致(show.scrollLeft >= marquePic1.scrollWidth)不成立,你可以多增加一个TD或者减少id="show"的宽度看看效果,可以循环的,我帮你优化了代码。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!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=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:940px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr><td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr></table>
</td><td id=marquePic2 valign=top></td></tr>
</table></div>
<script type="text/javascript">
var speed=18
marquePic2.innerHTML=marquePic1.innerHTML
function Marquee(){
if(show.scrollLeft>=marquePic1.scrollWidth){
show.scrollLeft=0
}else{
show.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
show.onmouseover=function() {clearInterval(MyMar)}
show.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>
试试我这个!
祝好运!---------^-^臭即是香^-^!
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<div id="show" style="overflow:hidden;width:940px;">
<table border=0 align=center cellpadding=0 cellspacing=0 >
<tr><td valign=top bgcolor=ffffff id=marquePic1>
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>01</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>02</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>03</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>04</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>05</a></td>
<td align=center><a href='#'><img src=images/zuopin.jpg width=158 height=200 border=0><br>06</a></td>
</tr></table>
</td><td id=marquePic2 valign=top></td></tr>
</table></div>
<script type="text/javascript">
var speed=18
marquePic2.innerHTML=marquePic1.innerHTML
function Marquee(){
if(show.scrollLeft>=marquePic1.scrollWidth){
show.scrollLeft=0
}else{
show.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
show.onmouseover=function() {clearInterval(MyMar)}
show.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>
试试我这个!
祝好运!---------^-^臭即是香^-^!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询