Re: Counting words in a webpage until click position



"regrat" <iteraktive@xxxxxxxx> wrote in message
news:1127387793.402331.167760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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.

<html>
<head>
<title>words.htm</title>
<script type="text/javascript">
function words() {
var oHTM = new ActiveXObject("htmlfile")
var sTXT = oHTM.parentWindow.clipboardData.getData("text");
if (sTXT == "") return;
var xTXT = sTXT + " ";
var yTXT = xTXT.replace(/^[^A-Za-z0-9]+/gi,"");
var zTXT = yTXT.replace(/[^A-Za-z0-9]+/gi," ");
var sMSG = "Selection has:";
sMSG += "\n" + sTXT.length + " bytes and";
sMSG += "\n" + (zTXT.split(" ").length-1) + " words.";
alert(sMSG);
}
</script>
</head>
<body>
<b>Select text, press Ctrl+C (copy to clipboard), then click "Count".</b>
<br><br>
<textarea cols="80" rows=10">
Four score and seven years ago our father brought forth upon this continent
a new nation ...
</textarea>
<br><br>
<input type="button" value="Count" onclick="words()">
<input type="reset" value="Clear">
</body>
</html>

<!-- Credit to:
http://javascript.internet.com/forms/word-count.html
-->


.



Relevant Pages

  • Re: statusbar
    ... thats not really what i am looking for the text may not change it has to ... Can somebody please give the javascript for it. ... > Put that in a webpage, ... Prev by Date: ...
    (microsoft.public.inetsdk.html_authoring)
  • Associating keys to a function
    ... I wonder if I can associate some keys to some ... function I create with JavaScript on my webpage. ... Prev by Date: ...
    (comp.lang.javascript)
  • Display th IP Address on your webpage using Javascript
    ... Display th IP Address on your webpage using Javascript ... Prev by Date: ...
    (comp.lang.javascript)
  • Cant see Javascript
    ... There is a webpage with a javascript on it, and I can't see the results with ... IE6 - I just get a little error sign in the lower left status bar. ... Prev by Date: ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Getting parameters from the get method
    ... > "Matt" wrote ... >> that will basically act as a wrapper from one webpage to another. ... >> wondering how I can use just Javascript and read those values passed to ... longer passes query strings from ActionScript links on local files? ...
    (comp.lang.javascript)