Topic awaiting preservation: image preload .onerror = stop loading? |
|
---|---|
Author | Thread |
Paranoid (IV) Inmate From: Northumberland, England |
posted 11-17-2003 00:18
Hi, |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-17-2003 19:34
If your image file names are in an array, just use the .length property of arrays to find out how many there are. |
Paranoid (IV) Inmate From: Northumberland, England |
posted 11-17-2003 23:10
Hi slime, I'm afraid they are not in an array. Basically it works something like this: |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-17-2003 23:13
That won't work, because the onerror function can't be called until the current code stops executing, and if you don't know when to stop the loop, it will never stop running; the browser will freeze and the onerror event will never be called. |
Bipolar (III) Inmate From: |
posted 11-18-2003 04:54
Hi, code: <html> |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 11-18-2003 05:19
That's clever. I'm not sure if it's 100% efficient, since it may be faster to download images in parallel rather than one at a time, but I've never tested it. |
Paranoid (IV) Inmate From: France |
posted 11-18-2003 06:42
Here comes a routine inspired by RoyW, with a retry procedure code: maxRetry = 50 The eval( "new Function( 'setTimeout( \" ... \",10 )' )" ) are ugly, but if I use a direct call instead of a setTimeout the recursion can bring a Stack Overflow. code: maxRetry = 50
|
Paranoid (IV) Inmate From: Northumberland, England |
posted 11-18-2003 17:19
Poi, if ever there was a man, then that man would be you |