iesniffer MarkText method
Return to Introduction  Previous page  Next page
Applies to
IESniffer component.  

function TIESniffer.MarkText(Browser: IWebBrowser2; const Text: String;  
  FontColor: TColor = clBlack; BackgroundColor: TColor = clYellow;  
  WholeWords: Boolean = False; MatchCase: Boolean = False; ScanFrames: Boolean = True;  
  const MarkID: String = 'IESnifferMark'): Integer; // returns number of marked words  

The MarkText method searches for all occurences of the Text on the Web page and marks it with specified foreground (FontColor parameter) and background (BackgroundColor parameter) colors.  
Browseris the IWebBrowser2 interface with some text which should be marked.  
Textis the word or phrase which should be marked in the HTML document.  
FontColorspecifies the font color to mark the found text.  
BackgroundColorspecifies the background color to highlight the text.  
WholeWordswhether the Text should match whole words only.  
MatchCasewhether the Text should match case.  
ScanFrameswhether to scan subframes of the web page (True by default).  
MarkIDidentifier of marked text which must be used if you plan to clear marks. (ClearMarks method can clear the marks from keywords with specified MarkID).  
Function returns the number of marked text fragments, or 0 if specified Text was not found on the page.  

procedure TForm1.IESniffer1WBDownloadComplete(Sender: TObject;  
  const URL: Stringconst Browser: IWebBrowser2);  
  // highlights AppControls keyword with yellow color  
  IESniffer1.MarkText(Browser, 'AppControls', clBlack, clYellow);  

See also
ReplaceText method;  
OnWindowLoad and OnWBDownloadComplete events.