title: How check WebBrowser completed fully?
body: <p>How to check when WebBrowser has fully completed? This code doesn't work for heavy AJAX websites. It will fire before the site has really completed and thus return HTML code while javascript is still running.</p>
  
  <p>I need to check when the website is FULLY completed. This code was tested with <a href="http://www.html5test.com" rel="nofollow">http://www.html5test.com</a></p>
  
  <pre><code>procedure Browser_DocumentComplete(ASender: TObject;
    const pDisp: IDispatch; var URL: OleVariant);
  var
    CurWebrowser: IWebBrowser;
    TopWebBrowser: IWebBrowser;
    Document: OleVariant;
    WindowName: string;
  begin
    CurWebrowser := pDisp as IWebBrowser;
    TopWebBrowser := (ASender as TEmbeddedWB).DefaultInterface;
    if (CurWebrowser = TopWebBrowser) and not Browser.Busy and (Browser.ReadyState &gt;= READYSTATE_COMPLETE) then begin
      FDocumentLoaded:=True;
      end;
  end;
  </code></pre>