Image onload will not be triggered when the image is loaded from cache. So if the user re-opens the same image the event won't be triggered. To prevent this (image cache) set a time stamp to the image src:
EX : img.src = src+"?timestamp="+(new Date())