Word Count for Firefox & Chrome

This may not be strictly related to online marketing, but in the course of my work, I often have to count the number of words and characters in a given text (like page titles and descriptions). If you’ve ever used Microsoft Word, you know how that works.

Well, before Firefox 4.0, there was a nice add-on to do it, but it’s not compatible with the new version (how annoying). So I’ve had to resort to desperate measures.

Just kidding. Firefox allows the creation of JavaScript bookmarks, so you can put anything into them, really, and perform useful tasks like counting words and characters with a click of a button. In fact, Chrome provides the same mechanism, so this works on both browsers.

Thanks to as post by Joe Maller and another one by Media College, I had everything I needed. The code is this:

javascript:d=window.getSelection()+'';%20d=(d.length==0)?document.title:d;%20alert(d.split('%20').length+' words, '+d.length+' characters');

To install this “button”, drag the WordCount link to your Firefox or Chrome bookmarks area and you’re done. Just select some text, click the “button” (you can test now by clicking the link above) and a message will pop up with those numbers for you.

Note: when selecting text, make sure there are no trailing spaces or you will get an extra word and, of course, an extra character (this may happen when you double-click or triple-click).


Edit (13/02/2010): To select text within iframes, try this code, posted by Thelizardreborn:


Or drag this WordCount link to your bookmark bar.

          0 Pings & Trackbacks

          Leave a Reply