The length property contains the number of Link objects that are in the document.links array.
<html>
<a href="http://www.java2s.com">B Page</a><br>
<a href="http://www.java2s.com">A Page</a><br>
<script language="JavaScript">
<!--
document.write(document.links.length," links.");
-->
</script>
</html>