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
> [email protected]
> 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
[email protected]
http://jquery.com/discuss/