TWebBrowser OnDocumentComplete event

i have a problem in OnDocumentComplete event of TWebbrowser ...
a message will pop up after the whole document(including multiple frames) is finished loaded ..(see attached code) ......

however, i accidentally found that it is not 100% working for certain website

it is continue loading to another page even though the message "Complete document was loaded" did pop up..

is there anyway i can make sure that the whole HTML page is 100% finished loaded regardless of how many frames, or how the page is contructed ?


procedure YourForm.OnDocumentComplete(
  Sender: TObject;
  const pDisp: IDispatch;
  var URL: OleVariant);
  currentBrowser: IWebBrowser;
  topBrowser: IWebBrowser;
  document: OleVariant;
  windowName: string;
  currentBrowser := pDisp as IWebBrowser;
  topBrowser := (Sender as TWebBrowser).DefaultInterface;
  if currentBrowser = topBrowser then
    ShowMessage('Complete document was loaded')
    document := currentBrowser.Document;
    windowName := document.ParentWindow.Name;
    ShowMessage(Format('Frame "%s" was loaded', [windowName]));

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should look in the help at the OnNavigateComplete2, OnDocumentComplete, example section.

It explains how to be sure that the page is fully loaded by using these 2 event handlers
chongkeng_woonAuthor Commented:
it did try ...but it doesn't work as well ...the given example in Help doesn't solve my problem ...
Strange, because I use this method very often, and it works really well for me...
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

chongkeng_woonAuthor Commented:
it works to most of the webpage, almost 95% no problem ..(sorry if i misunderstanding you) ...
but, got exceptional case, can you try using TWebbrowser to navigate the following url:

this is the exceptional case i mentioned ..
Hello Sir,

 You could try some logic like this

  loadcomplete : boolean;

  loadcomplete := true
--your processingcode
  loadcomplete := false;
  while not loadcomplete do sleep(100); //for example
  --back to start, in case of a loop

with regards,
Eddie ShipmanAll-around developerCommented:
It is happening because it is loading 5 FRAMES.
Pierre CorneliusCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
- Delete (Refund)

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer
Eddie ShipmanAll-around developerCommented:
ok, first page
loads and redirects via window.location call to

Then erol.html#11506x0&& has four frames on it and each of them
get loaded. A few of those frames ALSO has a frameset in it, hence
you getting mutliple notices in OnDocumentComplete.

Personally, This kind of crud is really a stupid way of designing
a web site. Whoever did this is a complete IDIOT even though it

Good luck at doing whatever you are trying to do.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.