Forum Moderators: coopster

Message Too Old, No Replies

Loading images in sequence

with or without javascript

         

Calydon

11:56 pm on Oct 14, 2004 (gmt 0)

10+ Year Member



In an old post on this site:
[webmasterworld.com...]

Michael proposes a javascript solution to allow a browser to load images in a particular sequence. However, in practice I have not been able to get his script to work.

Is there PHP solution to this problem? I just want a table of images to load from left to right, top to bottom, every time no matter what the size of the image.

Calydon

7:28 am on Oct 15, 2004 (gmt 0)

10+ Year Member



Got it going (finally - no thanks to you guys ;P i kid!)

There seem to be another accepted method of doing this with javascript - but I recommend against an onload img attribute because it isn't valid HTML and also it isn't supported by NS7 (Gecko).

Here is the script, hope it will help save someone else all the research I did.

var imgArray = new Array

("bg_01","bg_02","bg_03","bg_04","bg_05");
var len = imgArray.length
var imgDir = ""; //path to your images dir
var num = 0;

for (i = 0; i < len; i++) {

imageObj1 = imgArray[i] + "";
temp = eval(imageObj1 + " = new Image()");
temp.src = imgDir + imageObj1 + ".jpg";

}

function ImageSequence() {

eval("document."+imgArray[num]+".src = "+imgArray[num]+".src");
num = num + 1;

if (num < len) {
setTimeout("ImageSequence()", 1000);
}
}

coopster

12:59 pm on Oct 15, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Thanks, Calydon, and welcome to WebmasterWorld!