title: Detect when user clicks link, but aborts
body: <p>I am working on a Web CMS. When the user clicks on a link to move to a different page, or submits a form, I want a &quot;please wait&quot; animated GIF to show up in the top right corner to symbolize that loading is in progress.</p>
  <p>However, the user can cancel loading of the new page in their browser, for example by pressing the &quot;cancel&quot; button or ESC. In that case, they will stay on the current page as the browser stops loading the next page.</p>
  <p>How can I detect this in Javascript, and hide the &quot;wait&quot; icon again?</p>
  <blockquote>
  <p><strong>Edit:</strong> To address the &quot;you shouldn't do that, the browser already has it&quot; comments. I have two specific reasons for introducing a custom solution.</p>
  <ul>
  <li><p>I have AJAX buttons on the page. I need an activity indicator for them so the user isn't confused whether the click registered or not.</p>
  </li>
  <li><p>On slow connections with a lot of lag, some browsers' progress bar will move extremely slowly. I am in a real-life work situation when it takes ages until the throbber shows any kind of activity in IE6/7. This gives the impression that nothing is happening and the app is reacting very slowly, and that annoys me. I want an indicator that is constantly moving (like Safari's, for example).</p>
  </li>
  </ul>
  </blockquote>