title: Change url/state on beforeunload using history.replaceState
body: <p>I've looked for answers to this one, couldn't find one, I wonder if it's a bug, it seems browsers have bad support for this HTML5 function..</p>
  
  <p>I have only chrome and firefox to test. (latest stable versions).</p>
  
  <pre><code>$(function(){
  if ( window.history.state != null ) $( "#content" ).html( window.history.state.value );
  $( window ).bind( "beforeunload", function() { window.history.replaceState( { value:"remember me"}, "", document.location.href + "?param=rememberme" ); });
  });
  </code></pre>
  
  <p>Just try it. I was trying to change the current url on beforeunload, so I can keep data information in the url, so that when the user returns back to the page he will reload the page with the changed url thas has info in it.</p>
  
  <p>But it behaves weirdly on page reload.
  First off in chrome <code>window.history.state</code> doesn't even exist (not yet supported?), so the state cannot be fetched on reload. And on page reload the url change is not remebered.
  But if you go to another site and come back the url change is remebered.</p>
  
  <p>in firefox <code>window.history.state</code> exists and on page reload or history forward/back, the state is fetched correctly. But the url change doesn't work on page reload, the url changes correctly every 2 reloads. If you go forward/back the url change will be correctly handled.</p>
  
  <p>Anyone knows how to make that code work properly for page reloads(F5) and if chrome really still has no support for <code>history.state</code>? 
  Is the behaviour correct on page reload, or are the browsers not handling it well? </p>
  
  <p>If anyone can test it on Safari, I'd be curious to know how it works there.</p>
  
  <p>Just test the code there: <a href="http://www.braikar.com/stuff/test.html" rel="nofollow">http://www.braikar.com/stuff/test.html</a> </p>