Document.links

  • Revision slug: DOM/document.links
  • Revision title: document.links
  • Revision id: 184962
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

Summary

The links property returns a collection of all AREA elements and anchor elements in a document with a value for the href attribute.

Syntax

nodeList = document.links 

Example

var links = document.links;
for(var i = 0; i < links.length; i++) {
  var linkHref = document.createTextNode(links[i].href);
  var lineBreak = document.createElement("br");
  document.body.appendChild(linkHref);
  document.body.appendChild(lineBreak);
}

Specification

links

Revision Source

<p>
</p>
<h3 name="Summary">Summary</h3>
<p>The <b>links</b> property returns a collection of all AREA elements and anchor elements in a document with a value for the href attribute. 
</p>
<h3 name="Syntax">Syntax </h3>
<pre class="eval"><i>nodeList</i> = document.links 
</pre>
<h3 name="Example">Example </h3>
<pre class="eval">var links = document.links;
for(var i = 0; i &lt; links.length; i++) {
  var linkHref = document.createTextNode(links[i].href);
  var lineBreak = document.createElement("br");
  document.body.appendChild(linkHref);
  document.body.appendChild(lineBreak);
}
</pre>
<h3 name="Specification">Specification </h3>
<p><a class="external" href="http://www.w3.org/TR/2000/WD-DOM-Level-2-HTML-20001113/html.html#ID-7068919">links </a>
</p>
Revert to this revision