This is a JavaScript script for counting all external links of the web page. Just add this script after the tag </body>:

<script type="text/javascript">
var all_a = document.getElementsByTagName("a");
 
var this_link = window.location.toString();
this_link = this_link.substr(7,parseInt(this_link.indexOf("/",7)-7));
 
var external_links_count = 0;
 
for(var i=0; i<all_a.length; i++){
    if(all_a[i].href.indexOf(this_link)==-1){
        external_links_count++;
    }
}
 
alert("External links count is: "+external_links_count);
</script>
Share

6 Comments on Count of all external links of the web page

  1. ryan says:

    err.. what this script use for?
    sorry i dont get it

  2. ryan, it is written: “This is a JavaScript script for counting all external links of the web page.”. If you don’t understand this description, sorry, but I cannot explain you more. :)

  3. Emmanuel Makinde, please write which part of my explanation you don’t understand?

  4. wifi says:

    hmm.. why all external links need to count for?

    bdw, if i have google ads, will it be counted too?

  5. wifi, if you don’t need to count all external links, don’t do it. :) I think there are people who want to do it. And what about google ads, sorry, but I’ve not tried it. Thanks.

Leave a Reply

Info