title: Select menu not being restored when Back button used
body: <p>Consider a web page that has a select menu with a JavaScript event handler tied to the menu's onchange event that when fired reloads the page with a new query string (using the value selected in the menu).  </p>
  
  <p><strong>Issue:</strong> when the user hits the Back button, the page DOM is restored from the cache but NOT 
  the state of the select menu.  </p>
  
  <p><strong>Browsers affected:</strong> Firefox and Safari (which use a back/forward cache) </p>
  
  <p><strong>Example</strong>:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
  function reloadPage() {
      var menu = document.getElementById("select1");
      var val = menu.options[menu.selectedIndex].value;
      window.location.href = 'test.html?select1=' + val;
  } 
  &lt;/script&gt;
  &lt;form action="#" method="get" name="form1"&gt;
      &lt;select name="select1" id="select1" onChange="reloadPage();"&gt;
      &lt;option value="A" selected&gt;Option A&lt;/option&gt;
      &lt;option value="B"&gt;Option B&lt;/option&gt;
      &lt;option value="C"&gt;Option C&lt;/option&gt;
      &lt;option value="D"&gt;Option D&lt;/option&gt;         
      &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>View this page and notice that option A is selected.  Then select a different option (say option C) - the page is reloaded (with a query string, ?select1=C).  Then hit the Back button - the select menu continues to show Option C as selected.</p>
  
  <p><strong>Question:</strong> Does anyone know why the select menu isn't restored and how one could solve this issue?  I've used JavaScript in the past to force the form fields on a page to match the query string but there are issues with that approach (i.e., FF and Safari don't normally execute the onload event for the window when loading a page from the cache) and it seems like a hack to me.</p>
  
  <p>Any suggestions?</p>
  
  <p><strong>Update:</strong> It has just occurred to me that what might be going on is the following:</p>
  
  <ol>
  <li>option C is selected</li>
  <li>the page is cached</li>
  <li>the JavaScript loads the new URL</li>
  <li>hit the back Button</li>
  <li>option C is restored because it is
  what was cached prior to the
  JavaScript/page reload.</li>
  </ol>
  
  <p>So I think this isn't an issue of the browser not restoring the state of the select menu, it's an issue of timing.</p>