image.onload event 
Author Message
 image.onload event
I've set up a simple page where the user clicks on
the thumbnail picture and the main image loads it.
I wanted to cache the rest of the large images after
the page has loaded.  I wanted to do this one image
at a time, so have tried using .onload event set
agains the image I am loading to trigger the next
image to load.  I set this up on a test page
( http://www.*-*-*.com/ ) and have commented
it through out.  When the page loads, it still hit's the
server for all outstanding images in one go rather
than just loading one at a time, and I can't work out why.
Also I get an error message in IE4 (not implemented)
 against the onload event I have set up, but nothing in
 Netscape 4.5 ?

Any help appreciated !

Mark



Thu, 06 Feb 2003 03:00:00 GMT  
 image.onload event
On your web page try:
      bufferimages.onload = nextpic;
instead of:
      bufferimages.onload = nextpic();

Functions and methods have to passed without arguments and parentheses
when being assigned to an event statement.


: I've set up a simple page where the user clicks on
: the thumbnail picture and the main image loads it.
: I wanted to cache the rest of the large images after
: the page has loaded.  I wanted to do this one image
: at a time, so have tried using .onload event set
: agains the image I am loading to trigger the next
: image to load.  I set this up on a test page
: (http://www.umii.co.uk/test.htm) and have commented
: it through out.  When the page loads, it still hit's the
: server for all outstanding images in one go rather
: than just loading one at a time, and I can't work out why.
: Also I get an error message in IE4 (not implemented)
:  against the onload event I have set up, but nothing in
:  Netscape 4.5 ?
:
: Any help appreciated !
:
: Mark
:
:



Fri, 07 Feb 2003 03:00:00 GMT  
 image.onload event
Thanks Walter,

That fixed it, I'd been looking at it for ages...
Now the page caches the images, but
if someone on a slow connection chooses
a different image, it still loads that as well.
Before it was loading some 15
large images at once which on a slow
connection was not pleasant !

Mind you I've noticed if you interrupt the event by
selecting another thumbnail that has not cached
the whole process stops...., but I'll work out how to
fix that one myself ( hopefully ! ).

Mark


Quote:
>On your web page try:
>      bufferimages.onload = nextpic;
>instead of:
>      bufferimages.onload = nextpic();

>Functions and methods have to passed without arguments and parentheses
>when being assigned to an event statement.



>: image to load.  I set this up on a test page
>: (http://www.umii.co.uk/test.htm) and have commented



Fri, 07 Feb 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. cannot attach onload event to the window ?

2. trigger event onLoad of frame

3. Event Trapping for IFRAME onLoad?

4. Tweaking the document onload event handler

5. onLoad event to auto send form?

6. onLoad event for all frames

7. How to catch the OnLoad event of another form

8. OnLoad Event

9. onload event

10. onLoad event & IE5.0 compatibility

11. Body onload page to fire 2 events

12. Updating fields with the window onload event

 

 
Powered by phpBB® Forum Software