Page 1 of 1

"Finished" two times

Posted: Wed Sep 04, 2019 12:14 pm
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;

Re: "Finished" two times

Posted: Wed Sep 04, 2019 12:26 pm
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.

Re: "Finished" two times

Posted: Wed Sep 04, 2019 12:37 pm
by X11
Yes, JS do click() and ajax load content and update the part of page:

prn scrn http://prntscr.com/p1p7u4