<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"> <Inde>var curv=0vvar; 🎜>//時間間隔單位毫秒<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>{ <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><br> </div>可以自己配置,自己設定每張圖片切換的時間間隔,自己設定每張圖片的路徑(絕對、相對路徑都可以) <br>雖然很簡單,但很實用。 <br><br><div class="codetitle"><span><a style="max-width:90%" data="55666" class="copybut" id="copybut55666" onclick="doCopy('code55666')">複製程式碼<u></u></a> 代碼如下:</span></div> <div class="codebody" id="code55666">-/html/PUBL "IC DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <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><br> </div>