Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1026409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:04:41+00:00 2026-05-16T12:04:41+00:00

I’m wondering how I could have a JavaScript image rotator/slideshow, that each time it

  • 0

I’m wondering how I could have a JavaScript image rotator/slideshow, that each time it displays each image (for 5 seconds), it refreshes from the last time it has shown.

Also, as something else, but not requiered, I was wondering if it was possible to have a drop-down list of the image locations down the bottom (there are 12 images) that each links to the appropriate image and refreshes it every 3 minutes.

Here’s what I have so far. I know it’s outdated, but I can’t find anything more modern via Google…thanks!

var interval = 5; // delay between rotating images (in seconds)
var random_display = 0; // 0 = no, 1 = yes
interval *= 1000;

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23004/1281263292.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23008/1281263293.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23011/1281263293.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23013/1281263294.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23014/1281263294.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23020/1281263295.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23025/1281263296.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23022/1281263296.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23024/1281263296.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23033/1281263298.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23034/1281263298.jpg");
image_list[image_index++] = new imageItem("http://livetraffic.vicroads.vic.gov.au/images/23040/1281263299.jpg");
var number_of_image = image_list.length;
function imageItem(image_location) {
this.image_item = new Image();
this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) {
return(imageObj.image_item.src)
}
function generate(x, y) {
var range = y - x + 1;
return Math.floor(Math.random() * range) + x;
}
function getNextImage() {
if (random_display) {
image_index = generate(0, number_of_image-1);
}
else {
image_index = (image_index+1) % number_of_image;
}
var new_image = get_ImageItemLocation(image_list[image_index]);
return(new_image);
}
function rotateImage(place) {
var new_image = getNextImage();
document[place].src = new_image;
var recur_call = "rotateImage('"+place+"')";
setTimeout(recur_call, interval);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:04:41+00:00Added an answer on May 16, 2026 at 12:04 pm

    This should do it… tested in Firefox and a few others.

    <!DOCTYPE html>
    <html lang="en">
    <head> 
    <meta charset="utf-8" />
    <title>Camera Slideshow</title>
    <style>
    #wrapper {
        width:   400px;
        overflow:hidden;
    }
    #slideshow {
        position:relative;
        width:   10000px;
        -webkit-transition: all linear 500ms;
        -moz-transition:    all linear 500ms;
        -o-transition:      all linear 500ms;
        transition:         all linear 500ms;
    }
    .slide {
        float:   left;
        padding: 24px;
    }
    .slide img {
        width:   352px;
    }
    </style>
    </head>
    <body id="cams" class="">
        <div id="content" class="">
            <div id="wrapper">
                <div id="slideshow" style="left:0;"></div>
            </div>
            <div id="list">
                <select id="locations"></select>
            </div>
        </div>
    <script>
    var Images = [
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23004/1281263292.jpg", name: "Kings Way / Sturt St" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23008/1281263293.jpg", name: "Punt Rd / Swan St" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23011/1281263293.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23013/1281263294.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23014/1281263294.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23020/1281263295.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23025/1281263296.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23022/1281263296.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23024/1281263296.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23033/1281263298.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23034/1281263298.jpg", name: "Name of location" },
        { src: "http://livetraffic.vicroads.vic.gov.au/images/23040/1281263299.jpg", name: "WGF / Montague St" }
    ];
    Images.Current = 0;
    
    var App = {
        run: function(){
            var instance = this;
    
            this.addSlides();
    
            setInterval(function(){
                instance.refresh();
                instance.rotate();
            }, 5000);
    
            document.getElementById("locations").onchange = function() {
                var loc = document.getElementById("locations").value;
                if (loc>-1) {
                    Images.Current = (loc-1);
                    instance.rotate();
                }
            };
        },
    
        addSlides: function() { //352 x 288
            var limit = Images.length;
            var html  = '';
            var list  = '<option value="-1">Choose a location</option>';
    
            for (var i=0; i<limit; i++) {
                html += "<div class='slide'>" +
                        "   <img class='img' alt='" + i + "' title='" + Images[i].name + "' src='" + Images[i].src + "' />" +
                        "</div>";
                list += "<option value='" + i + "'>" + Images[i].name + "</option>";
            }
            document.getElementById('slideshow').innerHTML += html;
            document.getElementById('locations').innerHTML += list;
        },
    
        refresh: function() {
            var img  = document.getElementsByClassName('img')[Images.Current];
            img.src = Images[Images.Current].src + '?' + (new Date()).getTime();
        },
    
        rotate: function() {
            Images.Current++;
            if (Images.Current == Images.length) { Images.Current = 0; }
            var xpos = (Images.Current==0) ? 0 : Images.Current * -400;
            document.getElementById('slideshow').setAttribute('style', 'left: ' + xpos + 'px;');
        }
    };
    App.run();
    </script>
    </body> 
    </html>
    

    A few things…

    1. I didn’t fill in all the location
      names, but that should be easy
    2. The image file name is not imprtant,
      you could use anything, for example:
      http://livetraffic.vicroads.vic.gov.au/images/23008/1281263293.jpg
      is the same as
      http://livetraffic.vicroads.vic.gov.au/images/23008/hello.jpg
    3. There are a number of optimizations you could do but I didn’t bother for reasons of time and clarity.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.