Use document.links collection : document « Javascript Objects « JavaScript DHTML
- JavaScript DHTML
- Javascript Objects
- document
Use document.links collection
<html>
<head>
<title>Reference</title>
</head>
<body>
<a href="http://www.java2s.com">java2s.com</a>
<p>
<script type="text/javascript">
for (var i = 0; i < document.links.length; i++) {
var link = document.links[i];
document.writeln(link.title + " : " + link.href + "<br />");
}
</script>
</p>
</body>
</html>
Related examples in the same category