Wiki source code of Counting words in a Wiki page
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | For web pages which don't include a feature to count words or characters on the page, a simple workaround is to use a **bookmarklet**. A bookmarklet is a bookmark stored in a web browser that contains commands (usually in JavaScript) that add new features to the browser. Bookmarklets are supported by most modern web browsers, possibly with limitations on mobile devices. | ||
| 2 | |||
| 3 | __**HOW TO**__: | ||
| 4 | |||
| 5 | 1. Create any bookmark and store it in the __toolbar__ of your web browser. If it's stored elsewhere it will be much less practical and might not work for this specific purpose. | ||
| 6 | 1. Edit the bookmark | ||
| 7 | 11. change its name to e.g. "Count Words" or something significant to you | ||
| 8 | 11. change its URL to the following single line (copy-paste it): | ||
| 9 | 11*. javascript: (function(){var a=(document.selection?document.selection.createRange().text:document.getSelection()).toString();alert(a.length?"Characters: "+a.length+"\nWords: "+a.replace(/\s{2,}/g," ").split(" ").length:"No text selected.")})(); | ||
| 10 | 11. save the changes if needed in your browser, else simply return to this wiki page | ||
| 11 | 1. To use it, simple select part of the text on a web page and click the bookmark in the toolbar of your browser. | ||
| 12 | 1. A pop-up shows the character and word count | ||
| 13 | |||
| 14 |