Hey folks,
I somehow managed to create a script that locks up Mozilla (1.3)
tight. Here's the culprit, perhaps y'all can provide some insight
into what the trouble is. (This script was cobbled together from
several different word-count routines I found on the web, none of
which worked correctly in all cases.)
function trim(data)
{
i=0;
while (/\s/.test(data.charAt(i)))
{data=data.substring(i,data.length);}
i=data.length;
while (/\s/.test(data.charAt(i))) {data=data.substring(1,i);}
return data;
}
function countWords()
{
input=document.forms[0].elements[0].value;
input=trim(input);
wordList=input.split(/\s+/g);
output=wordList.length;
return output;
}
activated via a button: onClick="alert(countWords())"
Thanks for any help,
--David