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

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

You are here: irt.org | FAQ | JavaScript | Link | Q670 [ previous next ]

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

©2018 Martin Webb