DelphiFAQ Home Search:
General :: Web publishing :: JavaScript :: Document


Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Accessing all links in a document with JavaScript

Question:

Is there a way to access all the links in a document with javascript?

Answer:

You can access all the links in a document using the documents.links array. The link itself will display the href value, or you can specify the href@} property directly. You can get to the link text using the @[link.innerText property.

<BODY>
 <A href="http://www.yahoo.com/">Hello</A>
 <SCRIPT LANGUAGE=JAVASCRIPT><!--
 for (var i=0; i < document.links.length; i++) {
   var li = document.links[i];
   alert(li.href);
   alert(li.innerText);
 }
 //-->
</SCRIPT>
 </BODY>
 

Generated 8:01:52 on Jan 17, 2017