Count the number of links on the current page

August 28th, 2007

I was testing a Web page indexer the company I work for produces, and I needed a quick way of finding out how many links were on a page. The way I came up with was to create a Favorite/Bookmark containing the following JavaScript instead of a URL:

javascript:if(frames.length<1){alert('This%20page%20has%20'%20+%20document.links.length%20+%20'%20links.')}else{alert('Sorry.%20This%20page%20has%20frames!%20This%20bookmarklet%20only%20works%20on%20frameless%20pages.')}

The easiest way to create this bookmarklet is just to create a Favorite/Bookmark to the current, call it "Link count" and save it. Then go back in and change the properties of the Favorite/Bookmark, changing the URL to the above JavaScript and, if you want, choosing an alternative icon.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a comment