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 08: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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.37346 seconds
  • Memory Usage 3,436KB
  • Queries Executed 13 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (4)bbcode_code
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (73):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • pagenav_page
  • pagenav_complete
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates