I am displaying a bunch of thumbnail images and the latency can be very high (over a VPN) so I send all the thumbnails in a single file (like a sprite) and set the CSS background-image and background-position properties of a div to show the thumbnails. The problem I'm having is with IE6 and figuring out when the image has loaded... I'm using the BackgroundImageCache hack:
document.execCommand("BackgroundImageCache",false,true);
To check when the image is loaded I use this code:
$('<img>').attr('src', 'ThumbSpriteTest.png').load(function() {
$('.Thumbnails').css('background-image', 'url(ThumbSpriteTest.png)');
});
This works in every browser I've tried except IE6... even with the cache hack it is loading the image, firing the event, setting the background-image property and downloading the image again (and my .Thumbnail elements are blank while it re-downloads).
It seems to me that the cache hack is only changing the behavior of the CSS references and not the img tag. How can I tell when the background image is loaded without downloading it twice? Is it possible in IE6?
EDIT: Using: document.execCommand("BackgroundImageCache",true,true);
seems to work (with both parameters as 'true'). I'm having trouble finding any documentation on the BackgroundImageCache command and it's parameters (I've found plenty of examples of using it to fix the CSS problem, but they all use false,true
as parameters and don't explain them)... the bounty is still good for anyone with good information/documentation on the BackgroundImageCache command and it's parameters!
(I'm not sure why I'm excited to find something that works after wasting so many hours due to IE's shortcoming)