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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:34:01+00:00 2026-05-13T08:34:01+00:00

Is this below the right way to preload images? I have a table which

  • 0

Is this below the right way to preload images?

I have a table which changes background once a ‘select option’ is changed.
In the body of my page, I have this:

 <body onload="preload();">

And in my Form on the same page I have:

 <select onchange="swap();"><option bla bla></select>

And the js:

 function preload(){
 pic = new image(720, 65);
 pic.src = '../picture.jpg';
 }
 function swap(){
 document.getElementById("table_id_here").style.backgroundImage = '../picture.jpg';
 }

In the function swap() I guess the picture.jpg file is already preloaded, is that right?

Is there any way to check if the image has actually been cached (preloaded)?

  • 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-13T08:34:02+00:00Added an answer on May 13, 2026 at 8:34 am

    Use something like Firebug’s network tool to check if those images are loaded.

    Fiebug
    (source: getfirebug.com)

    I guess your codes should work, anyway this is a popular script used by Dreamweaver for image preloading:

    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    MM_preloadImages('img1.gif','img2.gif'); //add more if required
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically this code below returns the right information, but I need to add the
I have a very large file that looks like this (see below). I have
Background: This question relates to versions of Delphi below 2009 (ie without Unicode support
Edit: I have solved this by myself. See my answer below I have set
I've been learning C#, and I'm trying to understand lambdas. In this sample below,
How do I implement this method (see below)? I'm new to Objective-C and I'm
The code below gives me this mysterious error, and i cannot fathom it. I
I receive this message (see image below) when I try to edit in debugging.
I'm trying a very basic XPath on this xml (same as below), and it
I'm using this code, and I get the stack trace that is listed below.

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.