[Javascript] An image loader working in FF but not in Opera, Safari...

Troy III Ajnej trojani2000 at hotmail.com
Thu Jul 14 11:30:03 CDT 2005


I have to agree with Hakan,
the 'get elements by tag name' will return a collection of the specified tag 
that doesn't have any directly connected properties with that tag type.
The only chance that this script will work is, only if you have just one IMG 
in the coll, so the script returns entity not the collection and you will be 
able to get the 'complete' property of it.
otherwise, this script is broken, nonworking for all other cases where 
you've inserted more than one image inside the 'content' container.
If this is the case, non of the browsers will do the magic. You will get 
error containing somethin like can't get complete property from the 
collection

regards


>From: Hakan <hakan at backbase.com>
>Reply-To: "\[JavaScript List\]" <javascript at LaTech.edu>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Subject: Re: [Javascript] An image loader working in FF but not in 
>Opera,Safari...
>Date: Wed, 13 Jul 2005 15:01:16 +0200
>
>Hi Guillaume,
>
>Two things:
>
> >     var img = content.getElementsByTagName("img");
> >
> >     if ( img.complete ) {
>
>getElementsByTagName returns an array with the nodes matching the tag name. 
>This array doesn't have a "complete"-property, and I'm guessing that the 
>only reason this "works" in Firefox is because it will get here on window 
>load and, since both conditions hide the loading div, it gets hidden.
>
> > window.onload = checkDone;
>
>When this triggers, images should already have been loaded.
>
>I'm sorry, but this script seems to do nothing.
>
>Regards,
>H
>
>Guillaume wrote:
>>
>>Hi list,
>>
>>I've managed to build with Roger Roelofs an image preloading script.
>>It's working just fine in Firefox, but Safari and Opera won't catch the 
>>"loading image..." process, and just display the image when the page is 
>>loaded.
>>Here is the inline script:
>>
>><script type="text/javascript">
>>
>>loader += '<div id="loader" style="display:block;"><p>Loading 
>>data...<p/></div>';
>>
>>document.write(loader);
>>
>></script>
>>
>>
>><script type="text/javascript">
>>
>>function checkDone() {
>>
>>     var content = document.getElementById("content");
>>
>>     var img = content.getElementsByTagName("img");
>>
>>     if ( img.complete ) {
>>
>>         document.getElementById('loader').style.display = 'none';
>>
>>     } else {
>>
>>
>>
>>         document.getElementById('loader').style.display = 'none';
>>
>>
>>
>>             }
>>
>>}
>>
>>window.onload = checkDone;
>>
>></script>
>>
>>I have setup a test page to understand what's the script about. 
>><http://www.hablablow.com/devX/loadTest2/testXXX5.htm>
>>So any help on this is warmly welcome...
>>
>>Thanks.
>>
>>Guillaume.
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>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

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/




More information about the Javascript mailing list