links

HTML (DHTML)

links Collection

Internet Development Index

Retrieves a collection of all a objects that specify the HREF property and all area objects in the document.

Syntax

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

Possible Values

oCollArray of a objects.
oObjectReference to an individual item in the array of elements contained by the object.
iIndexRequired. Integer that specifies the zero-based index of the item to be returned.

Members Table

The following table lists the members exposed by the links object. Click a tab on the left to choose the type of member you want to view.

Attributes/Properties

PropertyDescription
length Sets or retrieves the number of objects in a collection.

Methods

MethodDescription
item Retrieves an object from the all collection or various other collections.
namedItem   Retrieves an object or a collection from the specified collection.
tags Retrieves a collection of objects that have the specified HTML tag name.
urns Retrieves a collection of all objects to which a specified behavior is attached.

Remarks

For a objects to appear in the collection, they must have a name and/or id property.

Example

This example shows how to display the HREF attribute of the third link defined in the document.

alert(document.links(2).href);

Standards Information

This collection is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 Non-Microsoft link.

Applies To

document