Word Count Bookmarklet

Have you ever needed to count words in a document that you're authoring, in an email or a web page? Or even better, count characters and make sure you conform to the 140 twitter de-facto standard?

Source (www.gbsheli.com)


Download Bookmarklet:


View Bookmarklet Code:

Bookmarklet Source Code:

javascript%3A%28function%28%29%7Bfunction%20f%28d%29%7Bvar%20t%3Bif%28d.getSelection%29t%3Dd.getSelection%28%29%3Belse%20if%28d.selection%29t%3Dd.selection.createRange%28%29%3Bif%28t.text%21%3Dundefined%29t%3Dt.text%3Bif%28%21t%7C%7Ct%3D%3D%27%27%29%7Bvar%20a%3Dd.getElementsByTagName%28%27textarea%27%29%3Bfor%28var%20i%3D0%3Bi%3Ca.length%3B++i%29%7Bif%28a%5Bi%5D.selectionStart%21%3Dundefined%26%26a%5Bi%5D.selectionStart%21%3Da%5Bi%5D.selectionEnd%29%7Bt%3Da%5Bi%5D.value.substring%28a%5Bi%5D.selectionStart%2Ca%5Bi%5D.selectionEnd%29%3Bbreak%3B%7D%7D%7Dreturn%20t%3B%7D%3Bfunction%20g%28d%29%7Bvar%20t%3Btry%7Bt%3Df%28d%29%3B%7Dcatch%28e%29%7B%7D%3Bif%28%21t%7C%7Ct%3D%3D%27%27%29%7Bvar%20fs%3Dd.getElementsByTagName%28%27frame%27%29%3Bfor%28var%20i%3D0%3Bi%3Cfs.length%3B++i%29%7Bt%3Dg%28fs%5Bi%5D.contentDocument%29%3Bif%28t%26%26t.toString%28%29%21%3D%27%27%29break%3B%7Dif%28%21t%7C%7Ct.toString%28%29%3D%3D%27%27%29%7Bfs%3Dd.getElementsByTagName%28%27iframe%27%29%3Bfor%28var%20i%3D0%3Bi%3Cfs.length%3B++i%29%7Bt%3Dg%28fs%5Bi%5D.contentDocument%29%3Bif%28t%26%26t.toString%28%29%21%3D%27%27%29break%3B%7D%7D%7Dreturn%20t%3B%7D%3Bvar%20t%3Dg%28document%29%3Bif%28%21t%7C%7Ct%3D%3D%27%27%29alert%28%27please%20select%20some%20text%27%29%3Belse%20alert%28%27Chars%3A%20%27+t.toString%28%29.length+%27%5CnWords%3A%20%27+t.toString%28%29.match%28/%28%5CS+%29/g%29.length%29%3B%7D%29%28%29


Rate it:


Tags:

Comments

Comments so far. Add yours.