[Project_owners] Image prefetching

Konstantin Svist fry.kun at gmail.com
Thu Mar 31 13:57:42 EST 2005


Excellent explanation.
Thanks!!

~Konstantin


On Thu, 31 Mar 2005 15:53:00 -0600, Todd Ross <todd at brainsick.com> wrote:
> Konstantin Svist wrote:
> > WOW, that actually works!
> > I've been looking for a way of hooking something up to imageloads...
> > strangely enough, tmpImage.onload = 'alert()' will not work at all...
> >
> >
> > Anyway, your problem is very simple - some of your images load BEFORE
> > your JS even gets to tmpImage.setAttribute(...). And since the image
> > is already loaded, the onload event will not be fired.
> > To fix it, swap that line with the previous one:
> >      for ( ... )
> >      {
> >          var tmpImage = new Image();
> >          // This is only for testing purpose
> >          tmpImage.setAttribute("onload", "alert(this.src);");
> >          tmpImage.src = ...;
> >      }
> 
> If you'd like to understand the difference between tmpImage.onload and
> tmpImage.setAttribute("onload", ...) then you should probably read:
> 
> http://www.xulplanet.com/ndeakin/article/290?show=c 
> 
> Todd
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org 
> http://mozdev.org/mailman/listinfo/project_owners 
>


More information about the Project_owners mailing list