![]() |
![]() ![]() ![]() |
acIESniffer component.
|
type
|
TacIESnifferEvent = procedure(Sender: TObject; const URL: String; const Browser: IWebBrowser2) of object;
|
|
property OnWBDownloadComplete: TacIESnifferEvent;
|
The OnWBDownloadComplete event occurs when a navigation operation finishes, is halted, or fails.
|
|
Write an OnWBDownloadComplete event handler to take specific action after the Web browser stops a downloading operation. For example, use the OnWBDownloadComplete event to stop an download indication that is started in an OnWBDownloadBegin event handler.
|
|
![]() |
|
Unlike the OnWBNavigateComplete2 event, OnWBDownloadComplete occurs even if the Web browser does not successfully navigate to an URL.
|
uses MSHTML; // introduces IHTMLDocument2 interface
|
|
procedure TForm1.acIESniffer1WBDownloadComplete(Sender: TObject;
|
const URL: String; const Browser: IWebBrowser2);
|
var
|
doc: IHTMLDocument2;
|
Collection: IHTMLElementCollection;
|
Element: IHTMLElement;
|
HTMLPage: String;
|
PlainText: String;
|
begin
|
try
|
doc := (Browser.Document as IHTMLDocument2);
|
Collection := doc.all;
|
Collection := Collection.Tags('BODY') as IHTMLElementCollection;
|
Element := Collection.Item(NULL, 0) as IHTMLElement;
|
|
HTMLPage := Element.OuterHTML; // read the HTML page
|
PlainText := Element.OuterText; // or just plain text
|
except
|
end;
|
end;
|
(![]() |
uses MSHTML; // introduces IHTMLDocument2 interface
|
|
procedure TForm1.acIESniffer1WBDownloadComplete(Sender: TObject;
|
const URL: String; const Browser: IWebBrowser2);
|
var
|
Doc: IHTMLDocument2;
|
BodyElement: IHTMLBodyElement;
|
TextRange: IHTMLTxtRange;
|
SearchFlag: Integer;
|
begin
|
try
|
// http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/findtext.asp
|
SearchFlag := 2 + 4; // 2 = Whole words only, 4 = Match case
|
|
Doc := Browser.Document as IHTMLDocument2;
|
BodyElement := Doc.body as IHTMLBodyElement;
|
TextRange := BodyElement.CreateTextRange;
|
try
|
while TextRange.findText('Delphi', MaxInt, SearchFlag) do
|
TextRange.pasteHTML('Delphi Rules!');
|
finally
|
TextRange._Release;
|
end;
|
except
|
end;
|
end;
|
OnWBDocumentComplete, OnWBDownloadBegin and OnWBNavigateComplete2 events;
|
MarkText and ReplaceText methods.
|