[Delphi] 웹페이지 로딩 완료 체크하기



브라우저 컴포넌트의 DocumentComplete 이벤트에서 확인 가능함 !!

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

end;


참고 : html 소스 얻기
WebBrowser1.OleObject.Document.DocumentElement.OuterHTML;


출처 : 델마당
http://www.delmadang.com/community/bbs_view.asp?bbsNo=17&bbsCat=41&indx=385363&keyword1=DocumentComplete&keyword2=

-----------------------------------------------------------

DocumentComplete 이벤트에서

while EmbeddedWB.ReadyState <> READYSTATE_COMPLETE do
    Application.ProcessMessages;