Image Rotator
Posted: Thu Jan 11, 2007 4:09 pm
My boss would like to see rotating images on his website. He saw a website use flash to do this and I refuse to use flash so I thought that javascript would be the best option but as usual, I can't get getElementById to work. :/
my latest attempt wrote:Code: Select all
var i = 0; var timeout = 0; var images = new Array('images/header-1.gif', 'images/header-2.gif', 'images/header-3.gif', 'images/header-4.gif', 'images/header-5.gif'); function rotateImg(img) { if (i >= 4) { i = 0; } alert("img = "" + img + ""\ni = " + i); i = i + 1; document.getElementById('test').setAttribute('img', img); timeout = setTimeout("rotateImg('" + images[img] + "')", 2500, images[img]); } rotateImg(0);