title: Wait until a page is fully loaded in WebBrowser Delphi
body: <p>I am using the code below to wait for a page to be fully loaded when I browse by code, and that works perfectly, but when I click on a link in a page, the <code>WebBrowser1DocumentComplete</code> or <code>WebBrowser1NavigateComplete2</code> event fires several times if the page contains frames, of JS etc.</p>
  <p>I would like to be able to wait for the page to load completely when I click on the link, but I don't know how.</p>
  <pre class="lang-pascal prettyprint-override"><code>WebBrowser1.Navigate(URL);
  repeat
    Application.ProcessMessages;
    Sleep(0);
  until WebBrowser1.ReadyState = READYSTATE_COMPLETE;
  </code></pre>