[Javascript] Image PreLoad

Flávio Gomes flavio at economisa.com.br
Thu Sep 21 13:38:25 CDT 2006


myPreload = document.createElement("img");

//myPreload.src = "http://www.google.com/intl/en/images/logo.gif";

// A couple of large images to test

//myPreload.src = "http://www.plantzafrica.com/vegetation/vegimages/funderstoreyzululand.jpg";

myPreload.src = "http://www.forestserviceni.gov.uk/our_forests/forests/east%20district/images/belvoir/belvoir_1.jpg";

myPreload.onload = function() { alert(" I'm Loaded! ");               //Fires on onload
                                document.body.appendChild(myPreload); //Append the image to the document
                                alert(" Here I am! ");                //Says "Hello"? =)
                                this.onload = "";                     // BUG FIX HERE
                              };



People please test this code for me?
On my Mozilla the onload event kept on spamming all the time...


Terry Riegel escreveu:

> Sorry, I was unclear in my original post. I would like to preload an  
> image and fire an event once it is loaded. Is this possible?
>
> Terrry
>
>
> On Sep 21, 2006, at 11:49 AM, Flávio Gomes wrote:
>
>> myPreload = document.createElement("img");
>>
>> myPreload.src = "http://www.google.com/intl/en/images/logo.gif";
>>
>>
>> Maybe this would work too:
>> <img src="http://www.google.com/intl/en/images/logo.gif" width="0">
>>
>> Both untested =)
>>
>> Terry Riegel escreveu:
>>
>>> Hello All,
>>>
>>> What is a good way to preload a single image?
>>>
>>> Terry
>>> _______________________________________________
>>> Javascript mailing list
>>> Javascript at LaTech.edu
>>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>>
>>
>> -- 
>> Flavio Gomes
>> flavio at economisa.com.br
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript


-- 
Flavio Gomes
flavio at economisa.com.br




More information about the Javascript mailing list