some ideas for loading images one by one

W

windandwaves

Hi

I have the following html:

<div id="menu">
<div id="m1"><a href="m1.php"><img src="m1.gif" alt="m1"></a></div>
<div id="m2"><a href="m2.php"><img src="m2.gif" alt="m2"></a></div>
<div id="m3"><a href="m3.php"><img src="m3.gif" alt="m3"></a></div>
<div id="m4"><a href="m4.php"><img src="m4.gif" alt="m4"></a></div>
<div id="m5"><a href="m5.php"><img src="m5.gif" alt="m5"></a></div>
</div>

and I want to load on the images (1-5), one at the time, loading one every
0.5 seconds.

I have some thought on how to do this, but i wanted to find the smartest way

function onload() {
for (i=1; i< 6; i++) {
el = getelementbyid('m'.i);
el = el.style.display = "none";
}
for (i=1; i< 6; i++) {
waiter(0.5)
el = getelementbyid('m'.i);
el = el.style.display = "none";
}


function waiter($seconds) {
....???
}

any hints?
 
E

|-|erc

windandwaves said:
Hi

I have the following html:

<div id="menu">
<div id="m1"><a href="m1.php"><img src="m1.gif" alt="m1"></a></div>
<div id="m2"><a href="m2.php"><img src="m2.gif" alt="m2"></a></div>
<div id="m3"><a href="m3.php"><img src="m3.gif" alt="m3"></a></div>
<div id="m4"><a href="m4.php"><img src="m4.gif" alt="m4"></a></div>
<div id="m5"><a href="m5.php"><img src="m5.gif" alt="m5"></a></div>
</div>

and I want to load on the images (1-5), one at the time, loading one every
0.5 seconds.

I have some thought on how to do this, but i wanted to find the smartest way

function onload() {
for (i=1; i< 6; i++) {
el = getelementbyid('m'.i);
el = el.style.display = "none";
}
for (i=1; i< 6; i++) {
waiter(0.5)
el = getelementbyid('m'.i);
el = el.style.display = "none";
}


function waiter($seconds) {
....???
}

any hints?


That will timeout with more than a few dozen images.



imagenum = 0

function onload() {
if (imagenum < 5) {
imagenum++
imid = "m" + imagenum
document.images(imid).src = imid + ".gif"
timerid = setTimeOut("onload()", 500)
}
}

Herc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top