<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Untitled Document</title><styletype= "Text/css">#tuijian{position:Absolute; Left:0px;Top:0px;width:100%;Height:1000px;Z-index:1;background-repeat:no-repeat; }#p1{position:Absolute;float: Left;margin:300px 0px 0px 0px;width:48px;Height:56px;Z-index:2;Background-image:URL (image/fact2.png)}#p2{float: Right;margin:300px 0px 0px 0px;width:48px;Height:56px;Z-index:3;Background-image:URL (image/fact4.png)}</style></Head><Body><DivID= "Tuijian"style= "Background-image:url (image/header.jpg)"> <DivID= "P1"class= "pages"onclick= "Dodo ( -1)"></Div> <DivID= "P2"class= "pages"onclick= "Dodo (1)"></Div></Div></Body></HTML><Scriptlanguage= "JavaScript">varjpg=NewArray (); jpg[0]="URL (image/header.jpg)"; jpg[1]="URL (image/ae.jpg)"; jpg[2]="URL (image/ad.jpg)";vartjimg=document.getElementById ("Tuijian"); //define a variable tjimg to receive the Id=tuijian DivvarXB=0;varN=0;functionChange () {XB++; if(XB==jpg.length) {XB=0; } tjimg.style.backgroundImage=JPG[XB]; if(n==0) {window.settimeout ("Change ()", +); //Call the change function every 1 seconds } }//The following is a manual change of picturesfunctionDodo (m) {n=1; XB=XB+m; if(XB<0) {XB=Jpg.length-1; //left end, start again from Xb=jpg.length-1. } Else if(XB>=jpg.length) {XB=0; //The right end, start again from Xb=0.} tjimg.style.backgroundImage=JPG[XB]; //change the background image}window.settimeout (change), +) //Call the change () function every 1 seconds</Script>
JavaScript Auto-change pictures