The <div> moving is not what you want because once it has scrolled off screen, it just leaves a blank space! You need 2 scroll each image on its own and check to see if each image is off screen and if it is then make it goto the end of the scroll so it keeps scrolling around constantly.
The HTML tag marque (i think thats it) does a similar thing but on each scroll it leaves a gap which would look silly. Plus I think it only works in IE.
Try this script I wrote from scratch:
<script>
// CONFIG:
target = "_top";
height = 150;
speed = 3;
// as many images as u want:
images = new Array("1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg");
// width of images (same order as above):
widths = new Array(100, 60, 120, 170, 100);
// link for each image:
links = new Array("1.php", "2.php", "3.php", "4.php", "5.php");
// alternate text for images:
alts = new Array("1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg");
// CODE:
positions = new Array();
x = 0;
i = 0;
for (i=0; images[i]; i++) {
document.write("<a href='" + links[i] + "' target='" + target + "'>");
document.write("<img src='" + images[i] + "' style='position:absolute; top:0px; ");
document.write("left:" + x + "px; width:" + widths[i] + "px; height:" + height + "px;' ");
document.write("alt='" + alts[i] + "' id='img_" + i + "' border=0></a>");
positions[i] = x;
x += widths[i];
}
width = x;
function scroll() {
for (i=0; images[i]; i++) {
positions[i] -= speed;
if (positions[i] + widths[i] < 0) {
positions[i] += width;
}
img = document.getElementById("img_" + i);
img.style.left = positions[i];
}
setTimeout("scroll()", 100);
}
scroll();
</script>
Just remember that it needs to have more images than can fit into the width of the frame or it will show some gaps.
For example, if the width of your frame is 500pixels and your largest image is 200pixels wide, then you will need to have at least a width 700pixels total for the widths of your images or it will show a gap in each rotation.
Also, all the images need 2 b the same height - and that height needs to be set at the top of the script.
AND as an added bonus - that script works in IE6 and NN6 when i tested it 🙂
Feel free to add me to ur links if ya want 🙂 Hope the script works how you want.
http://daphreeek.kicks-ass.net