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

超级简单的JS图片切换
<!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=utf-8" />
<script language="javascript">
var pic=0;
var isAutoplay=true;
var picname=new Array();
picname[0]="http://www.yasuoji120.com/uploads/110411/1-110411224941923.jpg";
picname[1]="http://www.yasuoji120.com/uploads/allimg/110418/1-11041Q35Q50-L.jpg";
picname[2]="http://www.yasuoji120.com/uploads/110429/1-110429112419417.jpg";


function down()
{
if(pic<=0)
{
  pic=picname.length-1;
}
else
{
  pic=pic-1;
}
var photo=document.getElementById('photo');
photo.src=picname[pic];
}
function auto()
{
down();
if(isAutoplay==true)
{
  setTimeout("auto()",1500);
}
}

</script>
<title>无标题文档</title>
</head>

<body onload="auto();">
<img src="http://www.yasuoji120.com/uploads/110429/1-110429112419417.jpg" id="photo"  />
</body>
</html>