Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to HighLight Multiple Lines?

Status
Not open for further replies.

sarav45

Technical User
Sep 25, 2001
5
IN
sir,
i have doubt in built-in "Find in Page" functions...
i want find multiple lines in a page...., but when i use the findText function , it is recognising single line strings , but not for the multple line strings.
i want to find that string and highlight it

pls help me in this regard..,
 
You're going to have to step through the DOM and find all the Text Nodes first. Once you find a text node, store it's parent in an array. Splice up the parent and children, and add a span to hold the child text node with a css class to highlight it. Now you'd want to rebuild the entire parent node, with the new span included.

There's got to be an easier way to do this, and I don't have time to write all this code right now... good luck. jared@eae.net -
 
hi jaredn,(thanks for ur reply)
actually i want to highlight the text in the textarea

this is the code:
txt = window.document.frmManualEdit.taFileContent.createTextRange();
txt.findText(str);
txt.select();
txt.scrollIntoView();


if str contains string without \n i.e multiline it is highlighting perfectly(works only for single line)

but if \n is found it is not working
thanks in advance
sarav
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top