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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

highlight some words in a html page

Status
Not open for further replies.

Horowitz

Programmer
Jan 29, 2005
30
GR
hi, all i want to do is simple (is it?...)

I have a page called "data.html" that contains some text, and the "index.html" that has a textbox and a submit button. When I click it i would like to open the "data.html" (that's easy) and set bkground "yellow" to all of the words found to be equal with the text of the textbox (I hope there is no case sensitivity, so Hello==hELlO). In the textbox i enter only one word.

Is it simple html code or a javascript function?, don't know
Any help about it?

Tnx
 
Can't really say that it helped me. Let me make something clearer.
The data page has only data, no scripts no nothing. As i call the data.html i want on the event onLoad of it to highlight the word. There are many data pages I have , so I'd like not to open them and add <script ... onLoad="..."> etc .

This I want is somehow to activate e.g. the data143.html page (popup ...) and highlight the word i specify in the textbox ...
 
You'll need to use some sort of client-side or server-side script to do this. Javascript is one posibility:

1. Recurse through all nodes in the HTML body.

2. If you find a text node, use regular expression/string functions to add a span tag around the text you're after: eg. mystring becomes <span class="highlight">mystring</span>.

3. Set stylesheet to whatever you want the highlighted text to do.

Jon
 
I wish you knew greek so I could understand you all better.
I'll try to reset my question and hope to make myself clearer.

1. The "data.html" file has in it only text.
2. I run the "index.html" and clik the button that has.
3. The data.html page should be opened and have highlighted, e.g backgroung="yellow", every "Hello" word found in the page (data.html)

I can't "speak" clearer.

Tnx guys... :)
 
You wrote:

As i call the data.html i want on the event onLoad of it to highlight the word.

To use the event handlers, you need to write some kind of script to do that, or recreate the page with server side scripting so it has the appropriate text highlighted. That's what the experts here have been trying to tell you.

Lee
 

Horowitz,

You do not need to modify data.html in any way if you open it in a popup, as you can attach an onload event and script to it without modifying the source one bit.

So... the URL I gave above would suit you perfectly.

Dan


The answers you get are only as good as the information you give!

 
Thanks anyway... I appriciate your help. I'll try in an other forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top