The event OnDocumentComplete
is fired for each FRAME
/IFRAME
in the main document.
If you want to ignore them try this:
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 take specific action when a frame or document is fully loaded into the Web browser. For a document without frames, this event occurs once when the document finishes loading. On a document containing multiple frames, this event occurs once for each frame. When the multiple-frame document finishes loading, the Web browser fires the event one final time.
Sender is the Web browser that is loading the document.
pDisp is the Automation interface of the top-level frame or browser.
When loading a document without frames, pDisp is the interface of the
Web browser. When loading a document with multiple frames, this is the
interface of the containing frame, except for the very last time the
event occurs, when it is the interface of the Web browser.
here
you have how to find an element and on the found element try to setElement.Style := 'visibility:hidden;'
. – Countrywide