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

求助,帮忙改下图片播放的代码
<head>
<script type="text/javascript" language="javascript">
var li = document.getElementsByTagName("li");
function zidong(){
if(a==0)document.getElementsByTagName("img")[0].src = "01.jpg";
document.getElementsByTagName("img")[0].src = document.getElementsByTagName("img")[a].src;
if(a == 4){a=0;}
else if(a<4){a+=1;}
}
window.onload = function (){
li[0].onmouseover = function (){genghuan(0);}
li[1].onmouseover = function (){genghuan(1);}
}
</script>
</head>
head的一部分代码

然后在body部分实现自动播放
<body>
<script>
var turn = setInterval(zidong,1000);
li[0].onmouseover=function() {clearInterval(turn);}
li[1].onmouseover=function() {clearInterval(turn);}
</script>
</body>
但是这里的
li[0].onmouseover=function() {clearInterval(turn);}
不好使了

还有,如果停止自动播放,再次启动自动播放后让图片在不是从最初的图片开始播放,而是在上一个图片的位置上继续播放,代码怎么写?

------解决方案--------------------
本帖最后由 showbo 于 2013-08-06 17:23:43 编辑
<!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" />
<title>图片轮播</title>
 
<style>
#tupian01
{
    position:absolute;
    width:180px;
    height:260px;
    overflow:hidden;
    left: 360px;
    top: 20px;
}
 
#anjian01
{
    position:absolute;
    left: 360px;
    top: 300px;
}
 
#number01
{
    position:absolute;
    left: 35px;
    top: 225px;