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 6733063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:43:28+00:00 2026-05-26T10:43:28+00:00

how do i randomly rotate the images without refreshing the page with setTimeout?? js:

  • 0

how do i randomly rotate the images without refreshing the page with setTimeout??

js:

  var bannerImages = new Array( );

  bannerImages[0] = "Banner1.jpg";
  bannerImages[1] = "Banner2.jpg";
  bannerImages[2] = "Banner3.jpg";
  bannerImages[3] = "Banner4.jpg";

  var randomImageIndex = Math.round( Math.random( ) * 3 );
  document.write( "<img alt=\"\" src=\"imgs/" + bannerImages[randomImageIndex] + "\">" );

`

  • 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-26T10:43:29+00:00Added an answer on May 26, 2026 at 10:43 am

    Just change the src attribute of the image:

    <img id="pic" src="http://jsfiddle.net/favicon.png" />
    
    function changeImage()
    {
        var bannerImages = new Array( );
    
        bannerImages[0] = "http://jsfiddle.net/favicon.png";
        bannerImages[1] = "http://jsfiddle.net/img/logo.png";
        bannerImages[2] = "http://jsfiddle.net/img/info-close.png";
    
        var image = document.getElementById('pic');
        var randomImageIndex = Math.floor( Math.random( ) * bannerImages.length );
        image.src = bannerImages[randomImageIndex];
    }
    window.setInterval(changeImage, 1000);
    

    Try it: http://jsfiddle.net/A3v8w/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to test banner (two css background images) and rotate them randomly on
I need to randomly fade my background images in and out. It will be
For some reason wordpress randomly inserts blank paragraph tags on my page. I'm finding
I'm using a php script to randomly show images. I've duplicated this script three
Randomly and without warning (or apparent reason), VS 2008 decided to act as if
I have list of images. Is it possible to have all the ads randomly
I have a randomly-sized array of items. I'd like to display one label for
Sometimes the randomly-generated letter equals to 'undefined' Anyone know why? Code: <script type=text/javascript> var
Visual Studio randomly crashes when adding/removing references and projects. Any thoughts why? Will installing
The expected probability of randomly selecting an element from a set of n elements

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.