Sorry, looks like some of my sample code didn't quite come through.

So basically I started just trying to create an image and not actually
insert it into the page, but just create it so the image would be downloaded
to cache.

So I tried this originally:

$(' ').attr('src','/images/blah.jpg');

That didn't work in IE so I just assigned the new image element to a
variable and it worked like this:

var somevariable = $(' ').attr('src','/images/blah.jpg');

But you could also assign it to an array item as well like I mentioned
earlier:

array[item] = $(' ').attr('src','/images/blah.jpg');




Feed-2 wrote:
> 
> 
> I didn't quite understand your solution, ekallevig. Can you explain it
> again, please?
> 
> I also tried Jannik's solution but it didn't work... it gives me an
> error saying that $img has no properties.
> 
> On Dec 14, 1:41 pm, ekallevig  wrote:
>> I figured it out last night after I posted this. I just needed to assign
>> the
>> new element to a variable of some sort (or in my case an array item). I
>> already had created an array to keep track of whether or not each image
>> had
>> already been preloaded (to avoid duplication), so instead of setting
>> those
>> array values to true/false, I just assigned the new image to them and it
>> worked like a charm in all browsers.
>>
>> myimagearray[theimageindex] = $(' ').attr('src',buildThePathHere);
>>
>> or you could do it without jquery:
>>
>> myimagearray[theimageindex] = new Image();
>> myimagearray[theimageindex].src = buildThePathHere;
>> --
>> View this message in
>> context:http://www.nabble.com/preloading-images-with-jquery-in-IE-tp14330317s...
>> Sent from the jQuery General Discussion mailing list archive at
>> Nabble.com.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/preloading-images-with-jquery-in-IE-tp14330317s27240p14353388.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

Reply via email to