<!DOCTYPE HTML><HTML><HeadLang= "en"> <MetaCharSet= "UTF-8"> <title></title> <styletype= "Text/css"> *{margin:0;padding:0}Body{background:#dddddd}#div1{width:100%;Height:100%; } </style></Head><BodyID= "Div1"onload= "Showbgimage ()"></Body></HTML><Script> functionShowbgimage () {varCurindex= 0; //Define start index varTimeInterval= +; //define the switching time, 1s=1000ms //To define an array of stored images vararr= NewArray (); arr[0] = "Images/240.png"; //assign a value to each item in the array, which is to add the image path strengtharr[1] = "Images/340.png"; arr[2] = "Images/240.png"; arr[3] = "Images/340.png"; arr[4] = "Images/240.png"; arr[5] = "Images/340.png"; SetInterval (changeimg, timeinterval); //call the Show Picture method (parameter: Method name and switch time) functionchangeimg () {varobj=document.getElementById ("Div1"); //get the element you want to set if(Curindex==Arr.length- 1) {Curindex= 0; } Else{Curindex+= 1; } obj.style.backgroundImage= "URL (" +Arr[curindex]+ ")"; //set the background picture to get the element }} </Script>
JS Replacement Background Map