When user clicks on a button i load an array of images (there could be from 1 to 1000...). Is it possible somehow detect when last image is loaded?
Asked
Active
Viewed 170 times
0
-
when last image is loaded? means you asked abt TIME...? – Pandian Feb 22 '13 at 13:29
-
How are you loading the array of images? – andyb Feb 22 '13 at 13:29
-
You could attach `onload`event listener to the last image. – Teemu Feb 22 '13 at 13:29
-
@andyb just adding new elements to the DOM – user1692333 Feb 22 '13 at 13:33
-
@Pandian time, moment, end - nothing special, just need to remove loading message – user1692333 Feb 22 '13 at 13:34
-
Do you know how many images you're going to load before you start? – Robin van Baalen Feb 22 '13 at 13:35
-
@RobinvanBaalen i could – user1692333 Feb 22 '13 at 13:37
-
It would help if you could add some code to the question so we can see how you are adding the elements. – andyb Feb 22 '13 at 14:24
1 Answers
0
You can define and onload
event for each image and in the event increment a counter until the last one is loaded, which would be the length of your array.

james_torre
- 16
- 3
-
-
The `onload` event is not supported by the W3C standard; not all browsers need to or have to support this. – Robin van Baalen Feb 22 '13 at 13:43
-
good point. i was thinking you could use jQuery and the `load` handler. but that is still not perfect... http://stackoverflow.com/questions/821516/browser-independent-way-to-detect-when-image-has-been-loaded – james_torre Feb 22 '13 at 13:49