title: Can I detect when a user gets to a page using the back button?
body: <p><strong>Edit</strong>:  What I really need to know is if there is any javascript event that will reliably fire when the user arrives at the page via the back button.  I tried the <code>onload</code> event for the <code>body</code> element, but it doesn't fire on Firefox or Safari.</p>
  
  <hr>
  
  <p>I'm working with some old code that tries to prevent double-submission of form data by disabling all form submission buttons as soon as the user clicks one (by listening to the form's onSubmit event).  This code is applied to every form in the app, regardless of whether double-submission would even be a problem.</p>
  
  <p>The problem is that if the user hits the back button in Firefox or Safari, all the submit buttons are still disabled when he gets to the page.  On Firefox, they are even disabled after a refresh (only a Ctrl+F5 refresh will do it)!</p>
  
  <p>I've tried listening to <code>body</code>'s <code>onLoad</code> event, but FF and Safari don't fire that when you get to the page via back button.  (Interestingly, it is fired on a soft refresh on FF, even though the button stays disabled.)</p>
  
  <hr>
  
  <p>Here's a very simple HTML doc that will show what I mean:</p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;
  &lt;form name="theForm" id="theForm" action="test2.html"
        onSubmit="document.theForm.theButton.disabled = true;"&gt;
    &lt;input id="theButton" type="submit" name="theButton" value="Click me!" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>Note: I've tested on WinXP with IE8, FF3.5, Safari 4, Opera 9, and Chrome 2.0.  Only Safari and FF leave the button disabled when you use back to get to them.</p>