How to highlight the searched words ?

R

Roland

Hello there
I wrote one program in VC++ to highlight all words found in page
currently navigated in browser. For that I am just appending
"<span id=\"HTMLSEARCH\" STYLE=\"background-color: Highlight
COLOR:HighlightText\"\\>" it to words found so as to highlight the
words. My problem is that if the background color is same as
highlighted color them you can't read the word. I want to highlight
the word just like when you select any word using mouse. It highlights
the word and sets the background color which is exact reverse to
previous background color. How can I do this ?
Should I chage the background-color and color ?
 
S

SpaceGirl

Roland said:
Hello there
I wrote one program in VC++ to highlight all words found in page
currently navigated in browser. For that I am just appending
"<span id=\"HTMLSEARCH\" STYLE=\"background-color: Highlight
COLOR:HighlightText\"\\>" it to words found so as to highlight the
words. My problem is that if the background color is same as
highlighted color them you can't read the word. I want to highlight
the word just like when you select any word using mouse. It highlights
the word and sets the background color which is exact reverse to
previous background color. How can I do this ?
Should I chage the background-color and color ?

In VBScript it's really easy;

x = searchTerm

pagetext= (page content fetched from a database or something)

newpagetext = replace(pagetext,x,"<span class='highlighted'>" & x &
"</span>"

response.write newpagetext


--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 
S

Steve Pugh

You're missing the semi-colon between the two properties in your style.
Is this just a typo in your post?

You're using the system colours correctly
<http://www.w3.org/TR/CSS21/ui.html#system-colors>
but obviously the browsers (certainly IE6 and Opera 7.54) aren't smart
enough to apply the same adjustment to those colours that they apply to
real highlighting when the page background differs from the system
background colour.

So, you're probably better off defining your own hightlight colours and
using them instead of the system colours.
In VBScript it's really easy;

x = searchTerm

pagetext= (page content fetched from a database or something)

newpagetext = replace(pagetext,x,"<span class='highlighted'>" & x &
"</span>"

response.write newpagetext

Um, I don't think that answers the question at all.

Or is class="highlighted" some predefined classname in VBScript that
magically does what the OP needs with regards to the system colours?

Steve
 
S

SpaceGirl

Steve said:
You're missing the semi-colon between the two properties in your style.
Is this just a typo in your post?

You're using the system colours correctly
<http://www.w3.org/TR/CSS21/ui.html#system-colors>
but obviously the browsers (certainly IE6 and Opera 7.54) aren't smart
enough to apply the same adjustment to those colours that they apply to
real highlighting when the page background differs from the system
background colour.

So, you're probably better off defining your own hightlight colours and
using them instead of the system colours.



Um, I don't think that answers the question at all.

Or is class="highlighted" some predefined classname in VBScript that
magically does what the OP needs with regards to the system colours?

Steve

Yeah sorry... I misunderstood the question I think. Sorry!

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top