DHTML Collections
DOM Level 1 Specification.
Retrieves a collection of all AREA and anchor ( A ) elements in a document with a value for the href attribute.
[ collLinks = ] document.links |
[ oObject = ] document.links ( iIndex ) |
collLinks |
Reference to an array of elements contained by the object. |
oObject |
Reference to an individual item in the array of elements contained by the object. |
iIndex |
Integer indicating the item to be returned. |
The links collection returns an array, in source order, of all elements that has a destination link in the current document.
This collection can contain any combination of AREA and anchor ( A ) elements. Note that the collection includes only A objects that have a name and/or id property specified.
This collection is indexed first by name, then by identifier. If duplicate names are found, a collection of those named items is returned. Collections of duplicate names must subsequently be referenced by ordinal position.
The following example shows how the links collection is used to return the href values of all the links in this document. Press your browser back button to return to this page after.
<script language="JavaScript">
<!--
function getLinks ( ) {
var url = "This page contains the following links:\n";
for ( l = 0; l < document.links.length; l ++ )
url + "\n" + document.links [ l ].href;
alert ( url );
}
//>
</script>
Show me
document