Home > Article > Web Front-end > JavaScript method to get the number of hyperlinks in the page_javascript skills
The example in this article describes the method of using JavaScript to obtain the number of hyperlinks in the page. Share it with everyone for your reference, the details are as follows:
Here is a demonstration of using JavaScript to obtain the number of hyperlinks on a page. Friends who are interested can learn from it.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/js-total-link-num-codes/
The specific code is as follows:
<html> <head> <title>JavaScript取得页面的超链接数</title> <script language="javascript"> <!-- function getLinks(){ links = document.all.tags("A") total = links.length; alert("本页面共有" + total + "个超链接!"); } --> </script> </head> <body onLoad="getLinks()"> <a href="#">a</a> <a href="#">b</a> <a href="#">c</a> </body> </html>
I hope this article will be helpful to everyone in JavaScript programming.