Get all links on a page : links « Document « JavaScript Tutorial





<html>
<head>
<title>Get all links on a page</title>

</head>
<body>

<h1>Get all links on a page</h1>

<P>
<a href="http://www.java2s.com/">Example</a><br />
<a href="http://www.java2s.com/">Example</a><br />
<a href="http://www.java2s.com/">Example</a><br />
<a href="http://www.java2s.com/">Example</a><br />
<a href="http://www.java2s.com/">Example</a><br />
<a href="http://www.java2s.com/">Example</a><br />
</p>

<script language="javascript" type="text/javascript">
<!--

var allLinks = document.links;
for (var i=0; i<allLinks.length; i++) {
  document.write(allLinks[i].href+"<BR/>");
}

//-->
</script>

</body>
</html>










14.18.links
14.18.1.document.links
14.18.2.document.links.length
14.18.3.Get all links on a page
14.18.4.Change links