JRS: In article <Ku********************@comcast.com>, dated Thu, 22 Sep
2005 10:05:07, seen in news:comp.lang.javascript, McKirahan
<Ne**@McKirahan.com> posted :
"regrat" <it********@yahoo.it> wrote in message
news:11**********************@g14g2000cwa.googleg roups.com... It's possible create a javascript which counts all words in a webpage
until the point in which I click with the mouse.
Any suggests?
Will this approach work for you? Watch for word-wrap.
Avoiding word-wrap is the article author's responsibility, as you have
been told before.
function words() {
var oHTM = new ActiveXObject("htmlfile")
For the Web, one should not offer Microsoft-specific "solutions", and I
suspect that is one.
var sTXT = oHTM.parentWindow.clipboardData.getData("text");
<textarea cols="80" rows=10">
Four score and seven years ago our father brought forth upon this continent
Only one father?
a new nation ...
</textarea>
That does not count "all words in a web page" as the OP asked, but
counts the words in the text on the clipboard.
Its interpretation of "words" does not correspond with normal usage;
that's a pity, and "that's" an example.
The following gives me the number of "words" in the displayed text of my
current Web page, but the OP will probably wish to improve the
definition of what a word is :-
document.write(document.body.innerText.split(/\s+/).length)
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.