You can use “links” object array to traverse all the links present in an active document. You can open “Java Script Console” in the Firefox browser and run the following piece of code.

s = "Number of links: " + document.links.length + "\r\n";
for(i=0;i<document.links.length;i++) {
   s = "link " + i + ": " + document.links[i].href + "\r\n";
}
alert(s);