I wrote the script below and needless to say, it does not work... yet. I know I am not far and I need someone's help to tweak my script and let me know what was wrong with.
That would be greatly appreciated. Anyone?
I have this div in the middle of a page which has an image. I want the image.src to switch to the next image every 3 seconds.
Here's my html code:
<img src="pic3.jpg" id="image" />
Here's my js code:
window.onload = initLoad;
// Create a new image object
oImage = new Image;
// tie the object image object with your target id in your html code
oImage = document.getElementById("image");
//Create a new date object
var oCurrDate = new Date();
// Create a new time object
var oCurrentTime = oCurrDate.getSeconds();
//Loop through all images in the document
for(var i=0; i<document.images.length; i++)
//the current image remains so as long as 3 seconds or less have passed
while(oCurrentTime <= oCurrentTime + 3)
// if 3 seconds have not passed, your current picture remains on the screen
oImage.src = document.images[i].src;