www.webdeveloper.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 35

Thread: Rotating Images

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Posts
    8

    Unhappy Rotating Images

    Hi! I'm new here and still pretty much a novice in the web design field. In fact, the extent of my knowledge is basically no more than html.

    However, I'm trying to create a revolving image at the top of a personal website I'm creating and could use some help. Basically, I have three pictures. I want someone to come to my website and show one picture at the top. After about 2 seconds, I want the picture to change to the second and after another 2 secs to change to the third.

    Could anyone help me out with this? I would greatly appreciate it!

  2. #2
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Try this code:

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language="javascript" type="text/javascript">
    
    img2 = new Image()
    
    
    seconds = "2";
    
    function imgOne()
    {
    	setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    	document.myimg.src = 'two.gif';
    	setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    	document.myimg.src = 'three.gif';
    	setTimeout("imgOne()", seconds * 1000);
    }
    </script>
    
    </head>
    
    <body onload="imgOne();">
    <img src="one.gif" name="myimg">
    </body>
    </html>

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  3. #3
    Join Date
    Jun 2007
    Posts
    2

    rotate this

    these r old threads but if u guy r still out there, please lend a hand to a novice..

    my pics dont rotate. whats wrong with the code?


    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script language="javascript" type="text/javascript">

    img2 = new Image()


    seconds = "2";

    function imgOne()
    {
    setTimeout("<img src="/wp/wp-content/themes/ksc4/photos/7-6-9-1.jpg", seconds * 1000);
    }
    function imgTwo()
    {
    document.myimg.src = 'wp/wp-content/themes/ksc4/photos/7-6-9-1.jpg'';
    setTimeout("/wp/wp-content/themes/ksc4/photos/7-6-9-2.jpg", seconds * 1000);
    }
    function imgThree()
    {
    document.myimg.src = 'wp/wp-content/themes/ksc4/photos/7-6-9-2.jpg'';
    setTimeout("/wp/wp-content/themes/ksc4/photos/7-6-9-3.jpg", seconds * 1000); }
    </script/>

    </script></meta></head>

    <body onload="/wp/wp-content/themes/ksc4/photos/7-6-9-1.jpg();">
    <img src="/wp/wp-content/themes/ksc4/photos/7-6-9-2.jpg" name="pic 2"/>
    </body>
    </html>






    Quote Originally Posted by pyro
    Try this code:

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language="javascript" type="text/javascript">
    
    img2 = new Image()
    
    
    seconds = "2";
    
    function imgOne()
    {
    	setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    	document.myimg.src = 'two.gif';
    	setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    	document.myimg.src = 'three.gif';
    	setTimeout("imgOne()", seconds * 1000);
    }
    </script>
    
    </head>
    
    <body onload="imgOne();">
    <img src="one.gif" name="myimg">
    </body>
    </html>

  4. #4
    Join Date
    Jul 2010
    Posts
    2
    Quote Originally Posted by pyro View Post
    Try this code:

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language="javascript" type="text/javascript">
    
    img2 = new Image()
    
    
    seconds = "2";
    
    function imgOne()
    {
    	setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    	document.myimg.src = 'two.gif';
    	setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    	document.myimg.src = 'three.gif';
    	setTimeout("imgOne()", seconds * 1000);
    }
    </script>
    
    </head>
    
    <body onload="imgOne();">
    <img src="one.gif" name="myimg">
    </body>
    </html>
    Hey Thanks : good code and it works . I am new in Java script please give me more code like this.

  5. #5
    Join Date
    May 2011
    Posts
    2

    Add rotating images to a table

    Hey all,

    I was looking for a script that could rotate images for me and found this forum. Is there anyway to have this script run inside the contents of a table cell? We want to have some pictures rotate on our home page (www.pgsd.org). The three pictures at the top are in a table. Will this code work?

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by grubbsy View Post
    Hey all,

    I was looking for a script that could rotate images for me and found this forum. Is there anyway to have this script run inside the contents of a table cell? We want to have some pictures rotate on our home page (www.pgsd.org). The three pictures at the top are in a table. Will this code work?
    Please, don't hijack the others' threads. Especially not the old ones. Create your own Thread (see the up-left button: New Thread). And created it into the JavaScript Forum, not here, as it is a JavaScript related problem.

  7. #7
    Join Date
    May 2011
    Posts
    2
    Kor, I was merely trying to get more information about the same topic using the same script. That is not hijacking.

    Last time I post here.

  8. #8
    Join Date
    Feb 2012
    Posts
    12
    Quote Originally Posted by pyro View Post
    Try this code:

    Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <script language="javascript" type="text/javascript">
    
    img2 = new Image()
    
    
    seconds = "2";
    
    function imgOne()
    {
    	setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    	document.myimg.src = 'two.gif';
    	setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    	document.myimg.src = 'three.gif';
    	setTimeout("imgOne()", seconds * 1000);
    }
    </script>
    
    </head>
    
    <body onload="imgOne();">
    <img src="one.gif" name="myimg">
    </body>
    </html>
    How would you throw that into a constant loop? to where. it gose from img1 - img2 - img3 than back to img1 cause the way it is now it will loop every img besides the FIRST img.

  9. #9
    Join Date
    Feb 2012
    Posts
    12
    Disreguard that last post I figured it out after the imgone section i didnt have the code: Document.myimg.src - 'Photo.jpg'; (End Code) so ya... thanks for the code though! really helped

  10. #10
    Join Date
    Mar 2003
    Posts
    8
    Thank you so much! I'm just headed out the door and will give it a try when I get to work. Thanks again!

  11. #11
    Join Date
    Mar 2003
    Posts
    8
    OK, score one for my novice ways.

    Where would I plug in my pictures? The way I did it I keep getting a runtime error.

    Can you bold each place I need to do this? Also, does it make a difference if the pictures are of different sizes?

  12. #12
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script language="javascript" type="text/javascript">

    img2 = new Image()


    seconds = "2";

    function imgOne()
    {
    setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    document.myimg.src = 'two.gif';
    setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    document.myimg.src = 'three.gif';
    setTimeout("imgOne()", seconds * 1000);
    }
    </script>

    </head>

    <body onload="imgOne();">
    <img src="one.gif" name="myimg">
    </body>
    </html>

    Make sure that paths are correct. And, the images can be any size.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  13. #13
    Join Date
    Mar 2003
    Posts
    8
    This is what I have:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script language="javascript" type="text/javascript">

    img2 = new Image()


    seconds = "2";

    function imgOne()
    {
    setTimeout("http://devyne.org/Images/E&B.jpg", seconds * 1000);
    }
    function imgTwo()
    {
    document.myimg.src = 'http://devyne.org/Images/E&B.jpg';
    setTimeout("http://devyne.org/Images/family2.gif", seconds * 1000);
    }
    function imgThree()
    {
    document.myimg.src = 'http://devyne.org/Images/family2.gif ';
    setTimeout("http://devyne.org/Images/babyboy1.gif", seconds * 1000);
    }
    </script>

    </head>

    <body onload="http://devyne.org/Images/babyboy1.gif ();">
    <img src="http://devyne.org/Images/babyboy1.gif" name="myimg">
    </body>
    </html>

    However, I keep being told that line 33 has an expression expecting

  14. #14
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    You body tag should be this:

    <body onload="imgOne();">

    That tells the body to run the first function, imgOne()...

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  15. #15
    Join Date
    Mar 2003
    Posts
    8
    Oops, looks like we posted over each other.

    I've put in this:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script language="javascript" type="text/javascript">

    img2 = new Image()


    seconds = "2";

    function imgOne()
    {
    setTimeout("imgTwo()", seconds * 1000);
    }
    function imgTwo()
    {
    document.myimg.src = 'http://devyne.org/Images/E&B.jpg';
    setTimeout("imgThree()", seconds * 1000);
    }
    function imgThree()
    {
    document.myimg.src = ‘http://devyne.org/family.gif’;
    setTimeout("imgOne()", seconds * 1000);
    }
    </script>

    </head>

    <body onload="imgOne();">
    <img src="http://devyne.org/Images/babyboy1.gif" name="myimg">
    </body>

    And now I'm getting a runtime error "expression expected" on line 24, which is highlighted in red.

    On a side note, you can laugh at or criticize the pictures at will. They are just test pictures for now as the ones I want to use are not uploaded to the computer yet.
    Last edited by ferretfan7; 03-12-2003 at 07:47 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles