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

Q670 How can I tell which link within the links object array was clicked on?

irt.org | Knowledge Base | JavaScript | Link | Q670 [ previous next ]

Q670 How can I tell which link within the links object array was clicked on?

The links object array is very limited. All you can do is loop around the array comparing the href property of the link clicked:

<SCRIPT LANGUAGE="JavaScript"><!--
function checkWhichOne(url) {
    for (var i=0; i < document.links.length; i++)
        if (('http://somewhere.com/' + url) == document.links[i].href)
            alert('Link number ' + i + ' was clicked.');
//--></SCRIPT>

<A HREF="somepage.htm" onClick="checkWhichOne(this.href)">....</A>

Feedback on 'Q670 How can I tell which link within the links object array was clicked on?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


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