38 users online (0 members and 38 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 1
  2. Labels not displayed    Forum: CSS Forum
    Replies: 0
  3. javascript should be displayed in html    Forum: HTML Forum
    Replies: 0
  4. profile layout problems..alternate browsers    Forum: Myspace Forum
    Replies: 0
  5. Alternate for applet menu    Forum: Website Scripts Forum
    Replies: 0
  1. #1
    Talks_44's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    7

    Alternate between images being displayed

    Hello,

    I want to have 2 or more images that round robin rotate. When someone visits the image image #1 is displayed, the next time someone visits the image #2 is displayed and so on.

    Is there a simple way to rotate between images?

  2. #2
    jlwiebe's Avatar
    New User

    Status
    Offline
    Join Date
    May 2008
    Posts
    3

    Re: Alternate between images being displayed

    if you're just looking for a quick script to randomize b/w two images every time the page is refreshed, there are many resources online that will provide code for that...just as long as you reference the author in a comment in the head of your code. here's one i'm currently using for an architecture website under construction (excuse the pun).

    <td><script language="JavaScript">
    <!--

    /*
    Random Image Script- By JavaScript Kit (author)
    Over 400+ free JavaScripts here!
    Keep this notice intact please
    */

    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="image1.jpg"
    myimages[2]="image2.jpg"

    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<img src="'+myimages[ry]+'" border=0>')
    }
    random_imglink()
    //-->
    </script>
    </td>

    for this to work, simply insert this script with the comment in the table cell you would like to have the image appear in, and every time the page is refreshed the image will change randomly among the list of images in the script. this one is very basic as far as i can tell, and is just one way to get the job done.

  3. #3
    Hostnetric's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2008
    Posts
    10

    Re: Alternate between images being displayed

    Quote Originally Posted by jlwiebe View Post
    if you're just looking for a quick script to randomize b/w two images every time the page is refreshed, there are many resources online that will provide code for that...just as long as you reference the author in a comment in the head of your code. here's one i'm currently using for an architecture website under construction (excuse the pun).

    <td><script language="JavaScript">
    <!--

    /*
    Random Image Script- By JavaScript Kit (author)
    Over 400+ free JavaScripts here!
    Keep this notice intact please
    */

    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="image1.jpg"
    myimages[2]="image2.jpg"

    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<img src="'+myimages[ry]+'" border=0>')
    }
    random_imglink()
    //-->
    </script>
    </td>

    for this to work, simply insert this script with the comment in the table cell you would like to have the image appear in, and every time the page is refreshed the image will change randomly among the list of images in the script. this one is very basic as far as i can tell, and is just one way to get the job done.

    Thanks for posting this. I actually was looking for an easy way to do this on one of my own websites as well.



Tags for this Thread