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

Q737 How can you retrieve efficiently an images position in the document.images array?

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

By looping through the image object looking for an image with a name property equal to the one you are searching for:

<SCRIPT LANGUAGE="JavaScript"><!--
var position = -1;

for (var i=0;i<document.images.length;i++)
    if (document.images[i].name == 'thisone') position = i;
//--></SCRIPT>

©2018 Martin Webb