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.

How get the load status some pages

Post Reply
Chinyaev
Posts: 38
Joined: Mon Mar 13, 2017 3:23 pm

How get the load status some pages

Post 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;
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How get the load status some pages

Post 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.
Post Reply