That's exactly what I was trying to find out. Thanks for your input. So I take it the best method is to have a new Image object for each image to be preloaded (and making sure that any variables are not overwritten). Looks like the method Luke suggested in this thread is a good one to use.
Nathan Young -X (natyoung - Artizen at Cisco) wrote: > > Hi. > > The http request will NOT always succeed under the conditions you > describe in IE and I think sometimes in firefox (possible race > condition?). > > If you are preloading images for user experience reasons the stakes are > low, but if you need to track the requests from the server side (for > example for exit link tracking) discarding or re-using the img object > too quickly can cause requests to be dropped. > > ------->Nathan > > > > .:||:._.:||:._.:||:._.:||:._.:||:._.:||:._.:||:._.:||:._.:||:._.:||:._.: > ||:. > > Nathan Young > Cisco.com->Interface Development > A: ncy1717 > E: [EMAIL PROTECTED] > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of PragueExpat >> Sent: Tuesday, February 06, 2007 8:50 AM >> To: discuss@jquery.com >> Subject: Re: [jQuery] image preloading >> >> >> Thanks for testing this. >> >> I guess that means that although the variable gets >> overwritten, the image >> object remains in memory and the browser's http connection >> (that is pulling >> down the current image) remains active until the image is loaded. So >> basically the image object stays alive, but there is no way >> to access it >> from javascript. Sound about right? >> >> >> Luke Lutman wrote: >> > >> > Ok, did a quick test in FF and Safari :-) >> > >> > - The function doesn't wait, it makes all the requests at >> once (more or >> > less). >> > - The variable gets overwritten. >> > - It doesn't interrupt the download. >> > >> > One thing I did find was that if I do: >> > >> > var img = new Image(); >> > img.onload = function(){ >> > var that = this; >> > } >> > img.src = arguments[i]; >> > >> > >> > Then the variable 'that' will point to window, not img. >> > >> > However, if I do: >> > >> > var img = document.createElement('img'); >> > img.onload = function(){ >> > var that = this; >> > } >> > img.src = arguments[i]; >> > >> > Then the variable 'that' will point to img, and the event >> handler will >> > work as expected. >> > >> > Luke >> > >> > PragueExpat wrote: >> >> Luke, this is a great technique - thanks! >> >> >> >> As far as my original question, I am still curious to find out the >> >> following: >> >> >> >> With the following preload function: >> >> >> >> $.preloadImages = function() >> >> { >> >> for(var i = 0; i<arguments.length; i++) >> >> { >> >> img = new Image(); >> >> img.src = arguments[i]; >> >> } >> >> } >> >> >> >> does the browser completely download each image before the >> script changes >> >> the source and begins the next download or is/can the >> image download be >> >> interrupted by the variable being reassigned? >> >> >> >> Anyone? >> > >> > _______________________________________________ >> > jQuery mailing list >> > discuss@jquery.com >> > http://jquery.com/discuss/ >> > >> > >> >> -- >> View this message in context: >> http://www.nabble.com/image-preloading-tf2351203.html#a8829521 >> Sent from the JQuery mailing list archive at Nabble.com. >> >> >> _______________________________________________ >> jQuery mailing list >> discuss@jquery.com >> http://jquery.com/discuss/ >> > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > > -- View this message in context: http://www.nabble.com/image-preloading-tf2351203.html#a8831469 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/