Using CEF Browser I am trying to connect to the OnLoadEnd event to traverse the DOM tree.
For some strange reason, I get a VisitDom call 2 times.
procedure TForm1.FormCreate(Sender: TObject); begin FBrowser := TChromium.Create(Self); FBrowser.Parent := TWinControl(Self); FBrowser.OnLoadEnd := BrowserOnLoadEnd; FBrowser.Load('http://google.com'); end; procedure VisitDom(const Document: ICefDomDocument); begin ShowMessage(Document.Document.Name); end; procedure TForm1.BrowserOnLoadEnd(Sender: TObject; const Browser: ICefBrowser; const Frame: ICefFrame; HttpStatusCode: Integer; out Result: Boolean); var Visitor: TCefFastDomVisitor; begin if HttpStatusCode = 200 then begin Visitor := TCefFastDomVisitor.Create(VisitDom); FBrowser.Browser.MainFrame.VisitDom(Visitor); end; end;
Any idea why OnLoadEnd is being called multiple times?
source share