Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Image | Q24 [ previous next ]

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?'

©2018 Martin Webb