Click to See Complete Forum and Search --> : Javascript highlight words on a webpage


rryyjw
September 19th, 2006, 11:38 AM
Suppose there's a paragraph on the page which contains several lines of words. How can I highlight those words one by one, from the first one to the last one? It's just like reading through the paragraph.
I think I have to use TextRange object and its getClientRects method.
Could anyone help me? Very appreciate.

Thanks
Jie

PeejAvery
September 19th, 2006, 04:30 PM
Take a look at this (http://www.codeguru.com/forum/showthread.php?t=395929&highlight=range) thread. It isn't exactly what you want, but it can get you started.

szpilman
October 6th, 2006, 12:46 PM
it means that u need a timer.
setTimeOut function
then a function that parse word by word.

ok... i assume that u already got the function to parse the word by word.
after u got the word .. then u need to change the style (maybe u can bold it or italicize it)

u can treat that word as a span. then u can run the getInnerHtml function or outerHtmlFunction to modify the span. i havent try it, but, i guarantee it can work. :)

have a nice try :)

code?
October 12th, 2006, 02:08 PM
use a highlight CSS span code
use a variable or a cookie
i dont know but
write span class="highlight" or whatever, at the beginning of the word

but use a cookie of a variable to change the text of the word,
theres another, like text contains or find all elements by 'your word'

you can do it with javascript, i know that.
You absolutly need a css style script to change the color and stuff

Look for WEBuilder or the website "Blumentals" its good allaround page editor creator, 30 use free trial though, try just to leave it open, and the uses wont go down

HanneSThEGreaT
October 13th, 2006, 02:30 AM
I ran into this a while back, and this page covered all my highlighting needs. Check it out :)

http://www.nsftools.com/misc/SearchAndHighlight.htm