Doing A Deep Word Count Of A DIV?
May 17, 2011
One option that occurred to me is to loop through all nodes in the div and count the words in the nodeValue if it's a text node, or otherwise loop through the element's sub-nodes if it has them. You could do this recursively and therefore find all text nodes within the DIV and its sub-elements.The problem is this doesn't cover everything. Inputs and textareas have a value, not a nodeValue. You will want to ignore any "script" elements and perhaps others. Of course you can set up a list of exceptions and modify the algorithm a bit to allow for them.An attempt at the approach described so far is shown here: [URL]But what about select elements? Do you want the value or do you want the text inside the selected option? What if they're multi-select lists? etc.
View 3 Replies
ADVERTISEMENT
Nov 3, 2005
I know how to do a regular word count where it splits at the " ", but is there a way to split it at " " and " " [space and double space] in the same code so it accounts for people that double space also?
View 6 Replies
View Related
Aug 19, 2003
Would it be possible to have a webpage with normal HTML, but make it so the user can highlight some text, click a button and make it perform a word count on the selected text and disply the number of words in an alert()?
View 4 Replies
View Related
Jun 15, 2011
I am trying to find a word inside a string.the search his going fine but I need to know which word has been found in the string.
Code:
Code:
Now in the string only one value can be found at a time.So its either a1 or a2 or so on.....
View 4 Replies
View Related
Sep 15, 2009
I need a count down clock that will count down 18 minutes and reset itself at the end. also i need a counter that increases by +1 every 18 minutes starting at 0.
View 1 Replies
View Related
Jan 6, 2010
I'm grabbing an XML file with jQuery like this:
$
document
.ready
[code]....
View 8 Replies
View Related
Apr 23, 2010
I have a setup where I have a function, calling a function, calling a function. All functions do what they're supposed to do, but they don't return to the first function when all is done, so it doesn't display an alert that it's supposed to.
For those that don't want to look through tons of code and think they might know what I'm doing wrong, here's the "coles notes" version. code...
View 2 Replies
View Related
Jun 22, 2011
as you can see the items hide/show on click using a simple jQuery toggle. My question is, is it possible to link to my website with one section already expanded from an external source. I hope this question makes sense. Iv tried and failed by linking to the div id using #link but cant get that to work.
View 2 Replies
View Related
Aug 17, 2010
What happens if you do the following? - That is deep copy a jQuery selector.
[Code]...
I'm concerned whether the myObj.selector object will deep copy the whole of jQuery as part of the process. My initial tests did not show any obvious speed hit, but it is rather a basic test right now.
View 4 Replies
View Related
Jan 29, 2011
I'm trying to gather some information on any techniques or even plans to change the fundamental nature of the way the internet and http requests work. From both an advertising, and a usability perspective, the concept of a page load is becoming obsolete. Users expect instant results, and advertisers are becoming more concerned with time on site than they are with page views. You don't need a full page view to have an ad impression anyway. That said, there are plenty of techniques to make it so that your page can load new information without reloading the whole page. The problem is there doesn't seem to be any good way of making it so that AJAX calls can be linked to.
My site has a somewhat weak implementation of this: [URL]
Notice that it links you to the "APM" tab of that page, and if you click the other tabs they're all loaded via AJAX? You'll probably notice that initially it loaded the "Overview" tab, and after the page loaded, it then switched you to the APM tab. That's wonky behavior, and I don't like it, but there's not much that can be done about it as far as I know. The problem is, as far as I know, this deep linking technique becomes increasingly difficult to implement the more variations you have on a page's data.
For example, if you have pagination, then you need to make your deep linking code support all those variations as well. So my question is, is there a way to easily, FULLY AJAX a website, complete with the ability to deep link to any page state, without any wonky behavior (e.g. loading the "base page" first, and then after it's loaded, switching the data)? If not, has anyone heard of any plans to fundamentally rewrite the nature of HTML and HTTP requests so that web pages are no longer based on page loads, but state changes?
View 1 Replies
View Related
Jun 20, 2011
I have basic JS knowledge. I am trying to organize a JS timer which counts down to a specific date. After the target date is meet the timer starts to count up. Can someone point me to a JS sample which executes this count-down+target-date+then-count-up theme?
View 2 Replies
View Related
Nov 27, 2011
This might be more easily explained just by showing you the code. Basically, this is a function within a large class dealing with moving table rows around, and works in Chrome but no where else. Chrome understands "event.clientY" in this context while other browsers throw "event is undefined". Y is a correctly set global indicating the clientY of where the original click occurred.
Code:
set_bgcolor = function (t, r) {
var tr, i;
var currentY = pointer.y = event.clientY;
tr = tables[t].rows[r];
[Code]....
So, I'm just trying to get event.clientY to work for all browsers in this case, where an event handler might not easily be passed to the function.
Details:
I'm using third-party code to move rows of a table around. [URL]
It's a large piece of drag and drop code, but I'm trying to edit it so that at a point near the code's completion, it says whether the initial mouse click was above or below where the cursor has been dragged to. "Why" is a long story, but suffice it to say that there are functional differences when dragging the row up rather than down (up puts it above the hovered over row, while below puts in under that row), and I want to place a border line in there so that users know exactly where the row is going.
So you probably don't have to look at the whole code (which I can provide if you'd like), but my basic question is, how do I get the function to know where the current mouse pointer is this many levels deep in code. I could try to pass the event through all the layers, but I'm not good enough at javascript to make that work, and I'm not sure it would. Isn't the event the keypress (and not the current position?).
View 2 Replies
View Related
Aug 15, 2010
I want to change the onkeyup attribute of a id="duration" textbox which is buried deep inside the DOM tree.
View 3 Replies
View Related
Dec 24, 2010
I have a long paragraph and I have been asked to display words in red and green in such a way that that fist word should be red, 2nd word should be green, 3rd word should be red and 4th word should be green and so on. For example: this is just a sample.
View 3 Replies
View Related
Jun 18, 2010
I have two objects that I am trying to merge together using $.extend().
As long as I only use objects 1 level deep everything merges correctly.
objOne = {
face: "book",
captain: "crunch"
}
[Code]....
View 1 Replies
View Related
Mar 13, 2010
ielementfrompoint () gets an element at a given position (x,y). how can I get a single word (if it exists) from a given position? to sum up i need this: f(x,y)=word ( or null - in case there is no word). x, y is given NOT obtained with some mouseover event.
View 1 Replies
View Related
Jul 23, 2005
Assume we have this html:
<span>the quick brown fox</span>
and the mouse is hovering over the word "fox". Using javascript, is it possible to determine the word under the mouse *without* introducing additional elements such as an anchor?
View 2 Replies
View Related
Jul 20, 2005
I have what seems to
be a robust, working word counter script. I post it here to benefit
others that might want this in the future and so that if I ever lose
my copy I can come back here to find it :) Some other scripts that I
used for inspiration failed when confronted with whitespace before the
string or miscalculated when encountering linefeeds and other
non-space spaces, so I made mine better. Definition of words for this
exercise is contiguous groups of characters separated by whitespace. Code:
View 2 Replies
View Related
Aug 9, 2002
This JavaScript is a "Word Filter". It is a type of form validator. When the user submits some text, the validator will check the text for words that has to be filtered.
The words that have to be filtered must be added to the array swear_words_arr. When the user types the text and hits the submit button, if the text contains any word that is present in the array swear_words_arr, the form will not be submitted.
The script can be used for validation of swear words etc.
<html>
<head>
<title>Word Filter</title>
<!--BEGIN WORD FILTER JAVASCRIPT-->
<script language="JavaScript1.2">
// Word Filter
// (c) 2002 Premshree Pillai
// http://www.qiksearch.com
// http://javascript.qik.cjb.net
var swear_words_arr=new Array("bloody","war","terror");
var swear_alert_arr=new Array;
var swear_alert_count=0;
function reset_alert_count()
{
swear_alert_count=0;
}
function validate_user_text()
{
reset_alert_count();
var compare_text=document.form1.user_text.value;
for(var i=0; i<swear_words_arr.length; i++)
{
for(var j=0; j<(compare_text.length); j++)
{
if(swear_words_arr[i]==compare_text.substring(j,(j+swear_words_arr[i].length)).toLowerCase())
{
swear_alert_arr[swear_alert_count]=compare_text.substring(j,(j+swear_words_arr[i].length));
swear_alert_count++;
}
}
}
var alert_text="";
for(var k=1; k<=swear_alert_count; k++)
{
alert_text+="
" + "(" + k + ") " + swear_alert_arr[k-1];
}
if(swear_alert_count>0)
{
alert("The form cannot be submitted.
The following illegal words were found:
_______________________________
" + alert_text + "
_______________________________");
document.form1.user_text.select();
}
else
{
document.form1.submit();
}
}
function select_area()
{
document.form1.user_text.select();
}
window.onload=reset_alert_count;
</script>
<!--BEGIN WORD FILTER JAVASCRIPT-->
</head>
<body bgcolor="#FFFFFF">
<!--BEGIN FORM-->
<table cellpadding="10" style="border:2 solid #FF9900" width="200" align="center"><tr><td>
<form name="form1" method="post" action="post.cgi">
<center><font face="Times New Roman" size="6pt" color="#606060"><b><i>Word Filter</i></b></font></center>
<table><tr><td></td></tr></table>
<textarea rows="3" cols="40" name="user_text" style="border:2 solid #808080; font-family:verdana,arial,helvetica; font-weight:normal; font-size:10pt" onclick="select_area()">Enter your text here...</textarea>
<table><tr><td></td></tr></table>
<center><input type="button" style="background:#EFEFEF; border:2 solid #808080; width:100%; cursor:pointer" value="Submit" onclick="validate_user_text();"></center>
</form>
</td></tr></table>
<!--END FORM-->
</body>
</html>
View 1 Replies
View Related
Sep 29, 2002
Filter out words from multiple fields:
<html>
<head>
<title>Word Filter</title>
<!--BEGIN WORD FILTER JAVASCRIPT-->
<script language="JavaScript">
// Word Filter 2.0
// By Premshree Pillai
// http://www.qiksearch.com
var swear_words_arr=new Array("bloody","war","terror");
var swear_alert_arr=new Array();
var swear_alert_count=0;
function reset_alert_count()
{
swear_alert_count=0;
}
function wordFilter(form,fields)
{
reset_alert_count();
var compare_text;
var fieldErrArr=new Array();
var fieldErrIndex=0;
for(var i=0; i<fields.length; i++)
{
eval('compare_text=document.' + form + '.' + fields[i] + '.value;');
for(var j=0; j<swear_words_arr.length; j++)
{
for(var k=0; k<(compare_text.length); k++)
{
if(swear_words_arr[j]==compare_text.substring(k,(k+swear_words_arr[j].length)).toLowerCase())
{
swear_alert_arr[swear_alert_count]=compare_text.substring(k,(k+swear_words_arr[j].length));
swear_alert_count++;
fieldErrArr[fieldErrIndex]=i;
fieldErrIndex++;
}
}
}
}
var alert_text="";
for(var k=1; k<=swear_alert_count; k++)
{
alert_text+="
" + "(" + k + ") " + swear_alert_arr[k-1];
eval('compare_text=document.' + form + '.' + fields[fieldErrArr[0]] + '.select();');
}
if(swear_alert_count>0)
{
alert("The form cannot be submitted.
The following illegal words were found:
_______________________________
" + alert_text + "
_______________________________");
return false;
}
else
{
return true;
}
}
</script>
<!--END WORD FILTER JAVASCRIPT-->
</head>
<body bgcolor="#FFFFFF">
<!--BEGIN FORM-->
<font face="verdana,arial,helvetica" size="-1">
<form name="form1" method="get" action="" onSubmit="return wordFilter('form1',['name','email','subject','message']);">
<table>
<tr><td>Name :</td><td><input type="text" name="name"></td></tr>
<tr><td>E-mail :</td><td><input type="text" name="email"></td></tr>
<tr><td>Subject :</td><td><input type="text" name="subject"></td></tr>
<tr><td>Message</td><td><textarea name="message" rows="5" cols="30"></textarea></td></tr>
</table>
<input type="submit" value="Submit Form">
</font>
</form>
<!--END FORM-->
</body>
</html>
View 3 Replies
View Related
May 13, 2009
the title basically sums it up. how can i see if a word is in a url and then if it is, do something with it.
View 9 Replies
View Related
Aug 23, 2001
How do I check if a certain word exists in a text box? For example, if I set the word to be found to "word1", if the text box is "This is word1", and alert would come up saying that "word1" was found.
View 2 Replies
View Related
Dec 16, 2009
I have in javascript a text say I am an idiot
I want to do it. "I am...." and on mouseover it shows up I am an idiot.
How can I do it?
View 4 Replies
View Related
Feb 17, 2010
I've been looking everywhere for a script that counts up from 1 to 10, but can't find anything. I even searched the forums.
Basically just something that starts from 1 and then replaces itself with 2, and so on.
View 3 Replies
View Related
Jul 23, 2005
Is there any way for me to capture the DocumentBeforeSave event with an ActiveXObject("Word.Application") via Javascript in IE?
View 1 Replies
View Related
Jul 24, 2006
I am facing the following problem while exporting data to Word.
The current implementation is as described below:
I have a JSP file which has a link that enables you to export the data to Word.
Clicking on the link invokes a javascript function: .....
View 2 Replies
View Related