Rotate imgs

Discussion in 'Javascript' started by Fabri, Feb 7, 2005.

  1. Fabri

    Fabri Guest

    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.


    --
    Fabri
    (Lattepiù, chi può darti di più?)
    Fabri, Feb 7, 2005
    #1
    1. Advertising

  2. Fabri

    Erwin Moller Guest

    Fabri wrote:

    > 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
    Erwin Moller, Feb 7, 2005
    #2
    1. Advertising

  3. Fabri

    Evertjan. Guest

    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">

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
    Evertjan., Feb 7, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    629
    SwissCheese
    Dec 25, 2003
  2. RC
    Replies:
    1
    Views:
    854
    Bjoern Hoehrmann
    Aug 3, 2006
  3. IanJSparks
    Replies:
    0
    Views:
    1,127
    IanJSparks
    Jan 10, 2008
  4. shajnday
    Replies:
    19
    Views:
    710
    Neredbojias
    Aug 8, 2010
  5. Dave
    Replies:
    1
    Views:
    77
    Nik Coughin
    Sep 3, 2004
Loading...

Share This Page