Re: Counting words in a webpage until click position
- From: "McKirahan" <News@xxxxxxxxxxxxx>
- Date: Thu, 22 Sep 2005 10:05:07 -0500
"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
-->
.
- Follow-Ups:
- Re: Counting words in a webpage until click position
- From: Dr John Stockton
- Re: Counting words in a webpage until click position
- References:
- Counting words in a webpage until click position
- From: regrat
- Counting words in a webpage until click position
- Prev by Date: Re: Netscape Browser Resize problem
- Next by Date: What can I do while javascript submits the page??
- Previous by thread: Counting words in a webpage until click position
- Next by thread: Re: Counting words in a webpage until click position
- Index(es):
Relevant Pages
|