Is there a javascript (or some other) function i can use to count the number of words on a web page?
-
I don't want to count the words in a text box. I want to pass an http reference and return the number of words on the page.
-
Answer:
I can't think of an easy way to do it using javascript, but if you can use a server side script it shouldn't be too difficult. In PHP it would be: $string = "a lot of text, the content of your page or whatever"; $string = striptags( $string );//remove any html tags that would throw this off $string = preg_replace("/\w+/", " ", $string);//change all white space characters, or groups of white space to one space $string = trim($string);//remove any leading or trailing white space $array = explode(" ",$string);//change the string to an array broken on spaces $wordCount = count($array);
jack b at Yahoo! Answers Visit the source
Other answers
nope, you would have to use the innerText property and analise the string yourself, maybe use the split function to count words
Deep Thought
Related Q & A:
- In the simplest clearest language possible, can any one tell me step by step how to get a web page or domain?Best solution by Yahoo! Answers
- How do I download a picture so I can use it on my profile?Best solution by Yahoo! Answers
- What is a good printer that I can use for occasional use?Best solution by tomshardware.com
- How do I set up a web page?Best solution by Yahoo! Answers
- Is there a way I can use my camcorder as a webcam?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.