JS 图片向左滚动问题 网页设计
我想问下,我从网上弄来的代码,是一个图片向左滚动的JS,如果去掉网页中的<hmtl>-</head>以及两个<body></body>,只留下他的代码(放图片的表格以及一...
我想问下,我从网上弄来的代码,是一个图片向左滚动的JS,如果去掉网页中的 <hmtl>-</head> 以及 两个 <body></body> ,只留下他的代码(放图片的表格以及一段JS)图片就能正常滚动,不然不能,大家能帮我看下吗,我把代码贴出
<div id=demo style=overflow:hidden;height:139;width:500;background:#f4f4f4;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="http://www.lanrentuku.com/down/js/images/12460764740.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764741.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764742.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764743.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764744.jpg"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
谢谢大哥发的代码,您试过头部加上
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 这个信息后,火狐浏览器就不能正常滚动了,您看能不能改进下 展开
<div id=demo style=overflow:hidden;height:139;width:500;background:#f4f4f4;color:#ffffff><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="http://www.lanrentuku.com/down/js/images/12460764740.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764741.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764742.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764743.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764744.jpg"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
谢谢大哥发的代码,您试过头部加上
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 这个信息后,火狐浏览器就不能正常滚动了,您看能不能改进下 展开
展开全部
<div class="n" style="width:500px; height:150px; overflow:hidden;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="s1">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="/Item/Show.asp?m=2&d=71"><img src="/UploadFiles/2010-08/hxjlb/2010081001252234114.JPG" width="152" height="103" /></a><div>快乐星期六比赛中</div></td>
<td><a href="/Item/Show.asp?m=2&d=70"><img src="/UploadFiles/2010-08/hxjlb/2010081001223922772.jpg" width="152" height="103" /></a><div>美女与扬子</div></td>
<td><a href="/Item/Show.asp?m=2&d=64"><img src="/UploadFiles/2010-08/hxjlb/2010080610351069415.jpg" width="152" height="103" /></a><div>3号和6号</div></td>
<td><a href="/Item/Show.asp?m=2&d=63"><img src="/UploadFiles/2010-08/hxjlb/2010080510485422797.jpg" width="152" height="103" /></a><div>比赛中</div></td>
<td><a href="/Item/Show.asp?m=2&d=62"><img src="/UploadFiles/2010-08/hxjlb/2010080510485465003.jpg" width="152" height="103" /></a><div>济北比赛中</div></td>
</tr>
</table>
</td>
<td class="s2"></td>
</tr>
</table>
</div>
<script>
$(function(){
function roll(obj,s1,s2){
var play;
s2.html(s1.html());
function gd(){
if(obj.scrollLeft()<=s1.width()){
obj.scrollLeft(obj.scrollLeft()+1);
}else{
obj.scrollLeft(0);
}
}
play=setInterval(gd,20);
obj.hover(function(){clearInterval(play)},function(){play=setInterval(gd,20)});
}
roll($(".n"),$(".s1"),$(".s2"));
});
</script>
用我这个吧 很简单,兼容所有浏览器,需要在头部调用jquery插件,插件下载地址 http://jquery.com/,点左上的download下载 在你的页面头部调用下载的js文件即可
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="s1">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="/Item/Show.asp?m=2&d=71"><img src="/UploadFiles/2010-08/hxjlb/2010081001252234114.JPG" width="152" height="103" /></a><div>快乐星期六比赛中</div></td>
<td><a href="/Item/Show.asp?m=2&d=70"><img src="/UploadFiles/2010-08/hxjlb/2010081001223922772.jpg" width="152" height="103" /></a><div>美女与扬子</div></td>
<td><a href="/Item/Show.asp?m=2&d=64"><img src="/UploadFiles/2010-08/hxjlb/2010080610351069415.jpg" width="152" height="103" /></a><div>3号和6号</div></td>
<td><a href="/Item/Show.asp?m=2&d=63"><img src="/UploadFiles/2010-08/hxjlb/2010080510485422797.jpg" width="152" height="103" /></a><div>比赛中</div></td>
<td><a href="/Item/Show.asp?m=2&d=62"><img src="/UploadFiles/2010-08/hxjlb/2010080510485465003.jpg" width="152" height="103" /></a><div>济北比赛中</div></td>
</tr>
</table>
</td>
<td class="s2"></td>
</tr>
</table>
</div>
<script>
$(function(){
function roll(obj,s1,s2){
var play;
s2.html(s1.html());
function gd(){
if(obj.scrollLeft()<=s1.width()){
obj.scrollLeft(obj.scrollLeft()+1);
}else{
obj.scrollLeft(0);
}
}
play=setInterval(gd,20);
obj.hover(function(){clearInterval(play)},function(){play=setInterval(gd,20)});
}
roll($(".n"),$(".s1"),$(".s2"));
});
</script>
用我这个吧 很简单,兼容所有浏览器,需要在头部调用jquery插件,插件下载地址 http://jquery.com/,点左上的download下载 在你的页面头部调用下载的js文件即可
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2010-08-20
展开全部
这里有一个无缝滚动
可以试试
可以试试
参考资料: http://www.blueidea.com/common/shoutbox/redir.asp?2=s&id=12229
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<head>
<title>图片滚动</title>
</head>
<body>
<div id="marquee_demo" style="overflow:hidden;width:100%;text-align:center;border:1px solid #0066cc">
<table cellspacing="0" cellpadding="3" align="center" border="0">
<tr>
<td id="marquee_product1" valign="top">
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0">
<tr>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s1.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s2.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s3.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s4.jpg" border=0></a></td>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s5.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s6.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s7.jpg" border=0></a></td>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s8.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s9.jpg" border=0></a></td>
</tr>
</table>
</td>
<td id="marquee_product2" valign="top"></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed=30;
marquee_product2.innerHTML=marquee_product1.innerHTML;
function Marquee(){
if(marquee_demo.scrollLeft>=marquee_product1.scrollWidth){
marquee_demo.scrollLeft=0;
}
else{
marquee_demo.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
marquee_demo.onmouseover=function(){clearInterval(MyMar);}
marquee_demo.onmouseout=function(){MyMar=setInterval(Marquee,speed);}
</script>
</body>
</html>
<head>
<title>图片滚动</title>
</head>
<body>
<div id="marquee_demo" style="overflow:hidden;width:100%;text-align:center;border:1px solid #0066cc">
<table cellspacing="0" cellpadding="3" align="center" border="0">
<tr>
<td id="marquee_product1" valign="top">
<table width="100%" height="100" border="0" cellpadding="2" cellspacing="0">
<tr>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s1.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s2.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s3.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s4.jpg" border=0></a></td>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s5.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s6.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s7.jpg" border=0></a></td>
<td><a href="http://www.codefans.net"><img src="http://www.codefans.net/jscss/demoimg/wall_s8.jpg" border=0></a></td>
<td><a href="/"><img src="http://www.codefans.net/jscss/demoimg/wall_s9.jpg" border=0></a></td>
</tr>
</table>
</td>
<td id="marquee_product2" valign="top"></td>
</tr>
</table>
</div>
<script type="text/javascript">
var speed=30;
marquee_product2.innerHTML=marquee_product1.innerHTML;
function Marquee(){
if(marquee_demo.scrollLeft>=marquee_product1.scrollWidth){
marquee_demo.scrollLeft=0;
}
else{
marquee_demo.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
marquee_demo.onmouseover=function(){clearInterval(MyMar);}
marquee_demo.onmouseout=function(){MyMar=setInterval(Marquee,speed);}
</script>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询