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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:02:09+00:00 2026-06-06T14:02:09+00:00

im trying to use html and javascript to create a rotating logo on my

  • 0

im trying to use html and javascript to create a rotating logo on my site.

I want it to rotate on page load, and load them randomly.

Ive tried SO MANY THINGS! that i found on google, and i cant seem to get it to work. Im trying to avoid using php to do it.

i want to be able to have the random image in a tag like below, (if possible)

<img src="" />

So, just to sum it up.

I want to use “html” and “javascript” to create a script that everytime a page is refreshed, it loads a new logo from a directory on my server.

EDIT: what i have tried

<script type="javascript>
    Array.prototype.random = function () { 
        return this[ parseInt( Math.random() * this.length )  ];
    }

    var myImage=[ 
        "logo1.png",
        "logo1.png",
        "logo1.png",
        "logo1.png"
    ].random()

    document.wite(myImage)
</script>
  • 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-06-06T14:02:10+00:00Added an answer on June 6, 2026 at 2:02 pm

    You should avoid using document.write. Instead put an id attribute on the img tag, and retrieve it using document.getElementById. You can make it refresh at intervals using the setInterval method:

    <img id="logo" />
    <script type="text/javascript">
    var logos = ["logo1.png", "logo2.png", "logo3.png"];
    var currentLogoIndex = 0;
    function updateLogo() {
        document.getElementById('logo').src = logos[currentLogoIndex];
        currentLogoIndex++;
        currentLogoIndex %= logos.length;
    }
    window.setInterval(updateLogo, 1000);
    updateLogo();
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use an HTML form and javascript (i mention this, because
I am trying to use load() to place some html into a div on
I am trying to use html5lib to parse an html page in to something
I'm trying to use the 'edge.create' callback function of the Facebook javascript SDK to
I trying to create an HTML/CSS/JavaScript based list manager. I'm using text input fields
I'm trying to use javascript to create a button that has a onclick event
Im trying to create a div that will use jquery's lazy load to load
I am trying to use html() function of jquery over the specific child like:
alt text http://www.freeimagehosting.net/image.php?a55fa98f01.jpg Hi I am trying to use a HTML select box with
I'm trying to use QueryPath to manipulate HTML in PHP. It works fine until

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.