asp.net.ph

Skip Navigation Links

links Collection

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.

Syntax


[ collLinks = ] document.links
[ oObject = ] document.links ( iIndex )

Possible Values


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.

Members



Remarks

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.

Example

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 

Applies To

document



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note