I want to create an alert box after an image is loaded, but if the image is saved in the browser cache, the .onload
event will not be fired.
How do I trigger an alert when an image has been loaded regardless of whether the image has been cached or not?
var img = new Image();
img.src = "img.jpg";
img.onload = function () {
alert("image is loaded");
}