aversion
01-04-2007, 10:45 PM
I'm using JS to change an IMG src property and thus change the image but I need to know when that image has finished loading successfully.
for(v=0;v<docPicsLen;v++){
currentPic = docPics[v].src
currentPic = currentPic.slice(currentPic.lastIndexOf("/"))
docPics[v].src = newSize+currentPic;
}
This code changes all the images on the page with a certain classname, collected in an array called docPics. You can see that it's grabbing the original file name and then changing the source folder (to the value of newSize) to load a different image with the same name.
It works fine but I want to run a loading notification that terminates when the image change has completed and I can't find a way to check when that is.
I know how to check if an image has loaded if the image object is new to the page but because I'm only changing the SRC property of the IMG object things like img.complete don't work, it will always return true if the original image loaded correctly, no matter what's going on with the change.
Anyone have any ideas? If I can't find a way I'm going to have to replace the images altogether, which will be a pain in the neck.
for(v=0;v<docPicsLen;v++){
currentPic = docPics[v].src
currentPic = currentPic.slice(currentPic.lastIndexOf("/"))
docPics[v].src = newSize+currentPic;
}
This code changes all the images on the page with a certain classname, collected in an array called docPics. You can see that it's grabbing the original file name and then changing the source folder (to the value of newSize) to load a different image with the same name.
It works fine but I want to run a loading notification that terminates when the image change has completed and I can't find a way to check when that is.
I know how to check if an image has loaded if the image object is new to the page but because I'm only changing the SRC property of the IMG object things like img.complete don't work, it will always return true if the original image loaded correctly, no matter what's going on with the change.
Anyone have any ideas? If I can't find a way I'm going to have to replace the images altogether, which will be a pain in the neck.