That doesn't sound right. If you preload an image, it should be available right away as the src attribute of injected HTML. So your first method, even without preloading should have only have loaded the image once. With backgrounds it's generally the same, except that IE may sometimes reload backgrounds that result from injected HTML.
But let's go with what you say is (sort of) working for you, the background images.
In order to do so though, it would be helpful to know how you are getting the background images into the pop menu:
Please post a link to the page on your site that contains the problematic code so we can check it out.
However, even without knowing that, here is what I would suggest, use class.
So for instance, in your script code:
Code:
. . . MenuWidth="150px" //set default menu width.
var linkset=new Array()
//SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT
linkset[0]='<a class="lbg1" href="http://dynamicdrive.com">Dynamic Drive</a>'
linkset[0]+='<hr>' //Optional Separator
linkset[0]+='<a class="lbg2" href="http://www.jav . . .
Continue adding classes to each item as required. Then in your style section you could have something like:
Code:
.lbg1 {
display: block;
background: url(whatever.gif);
}
.lbg2 {
display: block;
background: url(whateverother.gif);
}
etc. for however many classes you've used. Then to preload these images, you can have a section in the body, just after the opening body tag:
Code:
<body>
<div style="position: absolute; left: -3000px; top: - 3000px; visibility: hidden;">
<a class="lbj1">dummy</a><a class="lbj2">dummy</a>
</div>
Put a dummy link (or any element really) in there for each of the classes you've used. It will not be seen but will preload the background images.
Now, preloading takes just as long as loading, so if a particular image hasn't completed its preload before it is required, it will still need to load on demand. So it is a good idea to optimize your images for smallest possible byte size.
Bookmarks