Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How to highlight the searched words ?

Reply
Thread Tools

How to highlight the searched words ?

 
 
Roland
Guest
Posts: n/a
 
      12-02-2004
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 ?
 
Reply With Quote
 
 
 
 
SpaceGirl
Guest
Posts: n/a
 
      12-02-2004
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
 
 
 
 
Steve Pugh
Guest
Posts: n/a
 
      12-02-2004
SpaceGirl <(E-Mail Removed)> 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
 
SpaceGirl
Guest
Posts: n/a
 
      12-02-2004
Steve Pugh wrote:
> SpaceGirl <(E-Mail Removed)> 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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
highlight words by regex in pdf files using python Peng Yu Python 6 03-18-2010 07:36 PM
highlight words by regex in pdf files using perl Peng Yu Perl Misc 0 02-20-2010 10:19 PM
Highlight Words shapper ASP .Net 4 11-27-2006 07:31 PM
How to highlight words with Indexing Service koffer ASP .Net 0 03-23-2005 10:44 AM
How to highlight words of a search PiGei ASP General 1 03-16-2005 03:08 PM



Advertisments