Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

VisitDom

Post Reply
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

VisitDom

Post by X11 »

In Memo1 i see "main frame load end", but in CefLog missing "DOMVisitor_OnDocAvailableSearch"

Code: Select all

procedure TMiniBrowserFrm.Chromium1LoadEnd(Sender: TObject;
  const browser: ICefBrowser; const frame: ICefFrame;
  httpStatusCode: Integer);
VAR
  TempVisitor : TCefFastDomVisitor2;
begin
  if Assigned(frame) then
  begin
    Memo1.Lines.Add('frame load end, name: ' + frame.Name);
    Memo1.Lines.Add('frame load end, url: ' + frame.Url);
  end;

  if frame.IsMain then
  begin
    Memo1.Lines.Add('main frame load end: ' + TimeToStr(now));
    Chromium1.Browser.MainFrame.ExecuteJavaScript(MemoJS.Text, Chromium1.Browser.MainFrame.Url, 0);
    TempVisitor := TCefFastDomVisitor2.Create(browser, Frame, DOMVisitor_OnDocAvailableSearch);
    frame.VisitDom(TempVisitor);

  end;
end;

procedure DOMVisitor_OnDocAvailableSearch(const browser: ICefBrowser; const frame: ICefFrame; const document: ICefDomDocument);
begin
  CefLog('CEF4Delphi', 1, CEF_LOG_SEVERITY_INFO, 'DOMVisitor_OnDocAvailableSearch');
  SimpleDOMIteration(document, frame);
end;
what could be wrong?
thanx
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: VisitDom

Post by salvadordf »

The method frame.VisitDOM can only be called in the render process.
https://magpcss.org/ceforum/apidocs3/pr ... isitor%3E)

The DOMVisitor demo sends a process message to the render process to create a TCefFastDomVisitor2 inctance and call frame.VisitDOM inside the GlobalCEFApp_OnProcessMessageReceived procedure, which is executed in the render process.
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: VisitDom

Post by X11 »

Oh! Thanks again.
It worked!
Post Reply