<div class="codetitle"> <span><a style="CURSOR: pointer" data="63952" class="copybut" id="copybut63952" onclick="doCopy('code63952')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code63952"> <br><script language="javascript"> <BR>var curIndex=0; <BR>//时间间隔 单位毫秒 <BR>var timeInterval=1000; <BR>var arr=new Array(); <BR>arr[0]="1.jpg"; <BR>arr[1]="2.jpg"; <BR>arr[2]="3.jpg"; <BR>arr[3]="4.jpg"; <BR>arr[4]="5.jpg"; <BR>arr[5]="6.jpg"; <BR>arr[6]="7.jpg"; <BR>setInterval(changeImg,timeInterval); <BR>function changeImg() <BR>{ <BR>var obj=document.getElementById("obj"); <BR>if (curIndex==arr.length-1) <BR>{ <BR>curIndex=0; <BR>} <BR>else <BR>{ <BR>curIndex+=1; <BR>} <BR>obj.src=arr[curIndex]; <BR>} <BR></script> <br><img id="obj" src="1.jpg" border="0" alt="js图片自动切换效果处理代码_javascript技巧" > <br> </div> <br>可以自己配置,自己设置每张图片切换的时间间隔,自己设置每张图片的路径(绝对、相对路径都可以) <br>虽然很简单,但是很实用。 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="55666" class="copybut" id="copybut55666" onclick="doCopy('code55666')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code55666"> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>图片自动跳转</title> <br><script language="javascript"> <BR>setInterval(test,1000); <BR>var array=new Array(); <BR>var index=0; <BR>var array= new Array("image/1.jpg","image/2.jpg","image/3.jpg","image/4.jpg","image/5.jpg","image/6.jpg","image/7.jpg","image/8.jpg","image/9.jpg","image/10.jpg"); <BR>function test() <BR>{ var myimg=document.getElementById("imgs"); <BR>if(index==array.length-1) <BR>{ index=0; }else{ index++; } <BR>myimg.src=array[index]; <BR>} <BR></script> <br> <br> <br><img id="imgs" src="image/1.jpg" alt="js图片自动切换效果处理代码_javascript技巧" > <br> <br> </div>