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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

"Finished" two times

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

"Finished" two times

Post by X11 »

Tell me please. Why is "Finished" inserted 2 times in the memo?
Thanx.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Chromium1.Initialized then
  begin
    Chromium1.WasHidden(False);
    Chromium1.SendFocusEvent(True);
    Chromium1.LoadURL(edUrl.Text);
  end
  else
  begin
    Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
    Chromium1.DefaultURL              := edUrl.Text;
    Chromium1.CreateBrowser(nil, '');
  end;
end;

Code: Select all

procedure TForm1.Chromium1LoadingStateChange(Sender: TObject;
  const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
begin

  if isLoading then
    begin
      StatusBar1.Panels[1].Text := 'Loading...';
      Memo1.Lines.Add('Loading...');
    end
   else
    begin
      StatusBar1.Panels[1].Text := 'Finished';
      Memo1.Lines.Add('Finished');
    end;
end;
User avatar
salvadordf
Posts: 4565
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: "Finished" two times

Post by salvadordf »

These are the code comments in the CEF project for the TChromium.OnLoadingStateChange event :

Code: Select all

  ///
  // Called when the loading state has changed. This callback will be executed
  // twice -- once when loading is initiated either programmatically or by user
  // action, and once when loading is terminated due to completion, cancellation
  // of failure. It will be called before any calls to OnLoadStart and after all
  // calls to OnLoadError and/or OnLoadEnd.
  ///
Perhaps the web page has some JavaScript code that loads more resources after the page has finished loading for the first time.
X11
Posts: 49
Joined: Thu Jul 25, 2019 10:15 am

Re: "Finished" two times

Post by X11 »

Yes, JS do click() and ajax load content and update the part of page:

prn scrn http://prntscr.com/p1p7u4
Post Reply