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/

Reply via email to