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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:06:57+00:00 2026-06-05T08:06:57+00:00

im trying to preload some images here. But what i need is to preload

  • 0

im trying to preload some images here. But what i need is to preload some images in an array, and show the progress.

This is working, but its giving me the GET 404 (Not Found) in console. But its working. What can i do to avoid this warning?

thanks!

function start(id) {
    var images = new Array();
    images[0] = "http://www.travelblog.org/Wallpaper/pix/tb_fiji_sunset_wallpaper.jpg";
    images[1] = "http://www.fantasy-and-art.com/wp-content/gallery/abstract-wallpapers/lion_hd_wallpaper.jpg";
    images[2] = "http://hidefwallpaper.org/wp-content/gallery/1_apple_wallpaper_02/90831582ea8e018759044f2820b518d1.jpg";
    imageObj = new Image();
    imageObj.src = images[id];
    imageObj.onload = function() {
        if (id == images.length) {
            alert('Carregou tudo');
        }
        if (id < images.length) {
            start(id + 1);
            alert(id);
        }
    }
}
start(0);​
  • 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-05T08:06:57+00:00Added an answer on June 5, 2026 at 8:06 am

    Your recursive call of your start function is executing one too many times which is why you’d get the 404 message as there is no array element with an index equal to the length of the array. Arrays are zero-based. So for example, when you call if (id < images.length) { when id is two, you increment id to 3 and call start again, however there is no images[3].

    Try this:

    var images = new Array();
    images[0] = "http://www.travelblog.org/Wallpaper/pix/tb_fiji_sunset_wallpaper.jpg";
    images[1] = "http://www.fantasy-and-art.com/wp-content/gallery/abstract-wallpapers/lion_hd_wallpaper.jpg";
    images[2] = "http://hidefwallpaper.org/wp-content/gallery/1_apple_wallpaper_02/90831582ea8e018759044f2820b518d1.jpg";
    
    function start(id) {
        imageObj = new Image();
        imageObj.src = images[id];
        imageObj.onload = function() {
            if (id == images.length) {
                console.log('Carregou tudo');
            }
            if (id < (images.length-1)) {
                start(id + 1);
            }
        }
    }
    start(0);​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to preload my images but it's not working. in my main stylesheet
Trying to preload images in a loop and it works fine but how to
I am trying to create an array images to preload by getting each of
I am trying to preload images for a visual Facebook app, but when I
I'm trying to preload about 150 images and I want to be able to
I'm trying to preload a number of images generated on the server to a
I'm trying to do something like this to preload all data, so I don't
I am trying to swap/animate preloaded jpg images using the following to preload the
Trying to get delayed_job working with a mongoid backend. The created job fails to
I am trying to preload a couple of images and would like my page

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.