|
|
O'Reilly Network Script Library -- Javascript Word Counter
With this small function you can calculate the number of words in an HTML document or inside specified elements and include it into your document dynamically. This function only uses the standardized DOM methods and does not take advantage of any proprietary techniques. Supported platforms are Mozilla, Netscape 6 and Internet Explorer 5.x. InstructionsIn the zip file you'll find a single file,
After including the script you have to choose what to count. You can count the words of a whole document or just an element (and its descendants). If you choose an element, you have to give its own ID, so that the function can access it:
showWords() with the correct arguments after the document has loaded. The first argument is the ID of the element, where the number will be printed, the second one is the ID of the counted element. If omitted, the complete document's text content is counted:
You're free to do this as often as desired. See Document Mathematics: Count Your Words for more details. |
|
|
|
--> |
||||||||