The OnDocumentComplete
event is OnDocumentComplete
for each FRAME
/ IFRAME
in the main document.
If you want to ignore them, try the following:
procedure TForm1.WebBrowser1DocumentComplete(Sender: TObject; const pDisp: IDispatch; var URL: OleVariant); begin // check that the event is raised for the top-level browser (not frames or iframes) if pDisp = TWebBrowser(Sender).ControlInterface then begin // do something nice... end; end;
From Delphi Docs:
Write an OnDocumentComplete event handler to perform certain actions when a frame or document is fully loaded into a web browser. For a document without frames, this event occurs once when the document finishes loading. In a document containing multiple frames, this event occurs once for each frame. When a document with multiple frames finishes loading, the web browser fires the event for the last time.
Sender is a web browser that downloads a document.
pDisp is a top-level frame or browser automation interface. When loading a document without frames, pDisp is the Web browser interface. When loading a document with multiple frames, this is the interface of the containing frame, with the exception of the last event that occurs when it is a web browser interface.
kobik source share