Rotate imgs

F

Fabri

I wonder if it is possible to rotate these images in this way:



<img name="one" src="one.gif">
<img name="two" src="two.gif">
<img name="three" src="three.gif">

I would like every 3 (or 4, 5...) seconds to appear 3 gif another way:

first loop:

1-2-3

second loop:

1-3-2

third loop:

2-1-3

fourth loop:

2-3-1

and so on...

Any help much appreciated.

Best regards.
 
E

Erwin Moller

Fabri said:
I wonder if it is possible to rotate these images in this way:



<img name="one" src="one.gif">
<img name="two" src="two.gif">
<img name="three" src="three.gif">

I would like every 3 (or 4, 5...) seconds to appear 3 gif another way:

first loop:

1-2-3

second loop:

1-3-2

third loop:

2-1-3

fourth loop:

2-3-1

and so on...

Any help much appreciated.

Best regards.


hi,

Make a callbackfunction using setTimeout("somefunction", time).
You set a function and the time that should elapse.
(Look it up.)
Then let that function end with another setTimeout().

You can change the src of an image like:
document.images["one"].src="somethingelse.gif";

Good luck.

Regards,
Erwin Moller
 
E

Evertjan.

Fabri wrote on 07 feb 2005 in comp.lang.javascript:
I wonder if it is possible to rotate these images in this way:

It is.
<img name="one" src="one.gif">
<img name="two" src="two.gif">
<img name="three" src="three.gif">

I would like every 3 (or 4, 5...) seconds to appear 3 gif another way:

I suppose you want the a script?
Next time please try it yourself first, you will learn from it.

=============

<script type='text/javascript'>
function rotate() {
var one = document.getElementById("one")
var two = document.getElementById("two")
var three = document.getElementById("three")
var temp = one.src
one.src = two.src
two.src = three.src
three.src = temp
setTimeout('rotate()',3000)
}
</script>

<body onload='rotate()'>

<img id="one" src="one.gif">
<img id="two" src="two.gif">
<img id="three" src="three.gif">
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top