Page 1 of 1

How get the load status some pages

Posted: Tue Jan 09, 2018 3:06 am
by Chinyaev
Hello, Salvador!

I need to get the status of the page to show / hide the load icon, but some sites (for example, instagram.com) always have value isLoading is True
I used this code. Instagram always returns isLoading is True.
Demo TabBrowser. Delphi XE7. Windows 10. Latest libraries.

Code: Select all

procedure TMainForm.Chromium_LoadingStateChange(Sender: TObject;
  const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean);
var
  itemIndex: integer;
begin
  if GetPageIndex(Sender, itemIndex) then
  begin
    ShowMessage(BoolToStr(isloading));
  end;
end;

Re: How get the load status some pages

Posted: Tue Jan 09, 2018 8:29 am
by salvadordf
Hi,

Nowadays many websites have multiple frames for the ads that might be loaded after the main frame and many other websites modify the HTML document with javascript after it's fully loaded.

It's not easy to give a precise loading status.

You can also use TChromium.OnLoadStart and TChromium.OnLoadEnd to check if frame.IsMain is True but read the code comments below.

CEFLoadHandler which handles TChromium.OnLoadStart and TChromium.OnLoadEnd has these comments.

Code: Select all

///
// Implement this structure to handle events related to browser load status. The
// functions of this structure will be called on the browser process UI thread
// or render process main thread (TID_RENDERER).
///
What they call the "UI thread" is not the main thread. Use mutexes if you need to store some information and don't modify the GUI from these events. Just send messages to the form.