chongkeng_woon
asked on
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.OnDocumentComplet e(
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).DefaultInterf ace;
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;
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.OnDocumentComplet
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).DefaultInterf
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;
ASKER
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...
ASKER
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 ..
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 ..
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.
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.
It is happening because it is loading 5 FRAMES.
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It explains how to be sure that the page is fully loaded by using these 2 event handlers