iesniffer ReplaceText method
Return to Introduction  Previous page  Next page
Applies to
acIESniffer component.  

function TacIESniffer.ReplaceText(Browser: IWebBrowser2; const OldText, NewText: String;  
  WholeWords: Boolean = False; MatchCase: Boolean = False; ScanFrames: Boolean = True): Integer; // returns number of marked words  

The ReplaceText method searches for all occurences of the OldText on the Web page and replaces it with NewText (can contain HTML tags).  
Browseris the IWebBrowser2 interface with some text which should be marked.  
OldTextis the word or phrase which should be replaced in the HTML document by NewText.  
NewTextthe new word or phrase to which the OldText should be replaced to.  
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).  
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);  
  // change all occurances of word "Delphi" to bold "Delphi Rules!" ;-)  
  IESniffer1.ReplaceText(Browser, 'Delphi''<b>Delphi Rules!</b>');  

See also
MarkText method;  
OnWindowLoad and OnWBDownloadComplete events.