Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q24 How do you count the number of images on a page?

irt.org | Knowledge Base | JavaScript | Image | Q24 [ previous next ]

Q24 How do you count the number of images on a page?

There is a simple answer to this question. However it does not always return the answer you would expect.

Since the introduction of JavaScript 1.1 the images object array has become supported. This is an array of all the images in the current document. One of its properties length tells you the number of images within the current document, e.g.

<script language="JavaScript1.1"><!--
    document.write(document.images.length);
//--></script>

This figure may however be distorted by image swapping, multiple uses of the same image and images within tables.

But used as a simple count it is quite effective.

Feedback on 'Q24 How do you count the number of images on a page?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.