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

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

Description
The ReplaceText method searches for all occurences of the OldText on the Web page and replaces it with NewText (can contain HTML tags).  
 
ParameterMeaning  
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.  

Example
procedure TForm1.IESniffer1WBDownloadComplete(Sender: TObject;  
  const URL: Stringconst Browser: IWebBrowser2);  
begin  
  // change all occurances of word "Delphi" to bold "Delphi Rules!" ;-)  
  IESniffer1.ReplaceText(Browser, 'Delphi''<b>Delphi Rules!</b>');  
end;  

See also
MarkText method;  
OnWindowLoad and OnWBDownloadComplete events.