![]() |
|
|
|||||||
![]() |
HTML - How to highlight the searched words ? |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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 |
|
|
|
|
#2 |
|
Posts: n/a
|
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 # |
|
|
|
#3 |
|
Posts: n/a
|
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 |
|
|
|
#4 |
|
Posts: n/a
|
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 # |
|