[Javascript] Listing Images on current page

David Dorward david at dorward.me.uk
Thu Sep 6 09:52:34 CDT 2007


On 6 Sep 2007, at 15:41, Peter Brunone wrote:

> Assuming you mean <img /> elements, you can do this:
>
> var aImages = document.getElementsByTagName("IMG");

No, you can't.

If you're using XHTML (which the / suggests), then the language is  
case sensitive and shouldn't contain any IMG elements.

> Now you have an array of all image elements in the page and you can  
> loop through it to analyze each element.

If you had 'img' then you would have a collection of the image  
elements, not an array.


-- 
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/





More information about the Javascript mailing list