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

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

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

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

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>

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.