View Single Post
Old 09-17-2012, 04:17 PM   PM User | #4
LearningCoder
Regular Coder

 
LearningCoder's Avatar
 
Join Date: Jan 2011
Location: The Pleiades
Posts: 849
Thanks: 67
Thanked 28 Times in 28 Posts
LearningCoder is an unknown quantity at this point
This is another example:

Code:
<html>
<body onload="window_onload()">
JS:
Code:
var currentImgNumber = 1;
var numberOfImages = 3;

function switchImage(){
   currentImgNumber++;
   document.imgAdvert.src = 'images/YourImage' + currentImgNumber + '.jpg';
   if(currentImgNumber == numberOfImages){
       currentImgNumber = 0;
   }
}

function window_onload(){
   setInterval("switchImage()", 3000);
}
This code changes the image within a div. You could slightly modify this to suit the background images.

Regards,

LC.

Last edited by LearningCoder; 09-17-2012 at 04:30 PM..
LearningCoder is offline   Reply With Quote