Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - How to highlight the searched words ?

 
Thread Tools Search this Thread
Old 12-02-2004, 01:38 PM   #1
Default How to highlight the searched words ?


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 ?


Roland
  Reply With Quote
Old 12-02-2004, 02:12 PM   #2
SpaceGirl
 
Posts: n/a
Default Re: How to highlight the searched words ?

Roland wrote:
> 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 #
  Reply With Quote
Old 12-02-2004, 02:36 PM   #3
Steve Pugh
 
Posts: n/a
Default Re: How to highlight the searched words ?

SpaceGirl <> wrote:
> Roland wrote:
>>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 ?


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

  Reply With Quote
Old 12-02-2004, 02:38 PM   #4
SpaceGirl
 
Posts: n/a
Default Re: How to highlight the searched words ?

Steve Pugh wrote:
> SpaceGirl <> wrote:
>
>> Roland wrote:
>>
>>> 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 ?

>
>
> 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
>


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 #
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump