Does document.links take all links from the website?

Asked

Viewed 55 times

1

I wonder if the JS command document.links take all links from the website or just from the page??

1 answer

2


According to the documentation, all elements <a> with href defined are listed by the function Document.links.

Document.links

The links read-only Property of the Document interface Returns a Collection of all <area> Elements and <a> Elements in a Document with a value for the href attribute.

Exemple:

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);
}

In free translation:

The read-only property links of the interface Document returns a collection of all elements <area> and elements <a> of a document with a value for the attribute href.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.