Entry
How can I access a link href through the links name (anchor) ?
May 30th, 2001 02:44
Spiff Spaceman, sharon,
I know what you mean: if you give a link a name, it is listed in the
anchors-array as well as in the links-array.But when you call it by name
you got the anchor, not the link, and this anchor has no href.
I found a workaround:
function showURL(linkName)
{
for(i=0;i<document.links.length;i++)
{if(document.links[i].name==linkName){alert(document.links[i].href)}}
}
You loop through the links-array to find the one with the asked name, so
you get the index of the link and can ask for href.
Hope it helps.