title: javascript history onpopstate
body: <p>I am trying to understand HTML5 history object. Here is a simple example which I started off with.</p>
  
  <pre><code>    function addDialog(){
           document.getElementById('d').style.display ='';
           history.pushState({name:"changed"},"","#newURL");
      }
  
      window.onpopstate = function(e){  
          alert(e.state);
      }
  </code></pre>
  
  <p>I have a <code>div</code> with an id <code>d</code> for which <code>display</code> property is <code>none</code>. On clicking a link, I will display the div and change the history so that new url will be loaded.</p>
  
  <p>When I copy paste the new url, <code>popstate</code> event is fired and I get <code>null</code> for <code>e.state</code>. </p>
  
  <p>From what I understand, if I load the new url <code>http://example.com#newURL</code>, <code>e.state</code> should point to the object which I pushed using pushstate.</p>
  
  <p>Please correct me if I am wrong and also I would like to know when <code>e.state</code> gets populated.</p>