<img> has an onload event that I can call when the image has fully loaded.
Is there any event that fires when a css background-image has loaded ?
Hi Anjanesh,
there isn’t, if you need to detect when a background-image has loaded, use Image preloading:
function OnImageLoaded (img) {
alert ("The image has been loaded: " + img.src);
}
function PreloadImage (src) {
var img = new Image ();
img.onload = function () {OnImageLoaded (this)};
img.src = src;
}
PreloadImage ("image1.png");
PreloadImage ("image2.png");
If you need further details, the following links will be useful:
Load, unload and state events,
onload event,
Image object.