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
e.g.  http://www.chatterboxgifts.co.uk/x11506.html

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 ?

thanks

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

chongkeng_woonAsked:
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.

GreybirdCommented:
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 ...
GreybirdCommented:
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:

http://www.chatterboxgifts.co.uk/x11506.html

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

 You could try some logic like this

var
  loadcomplete : boolean;

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

with regards,
padmaja.
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.

Pierre
EE Cleanup Volunteer
Eddie ShipmanAll-around developerCommented:
ok, first page http://www.chatterboxgifts.co.uk/x11506.html
loads and redirects via window.location call to
http://www.chatterboxgifts.co.uk/erol.html#11506x0&&

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
works.

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
Delphi

From novice to tech pro — start learning today.