title: How FB refreshes the page without reloading it (xmlHttpRequest) but Back button still works?
body: <p>How FB refreshes the page without reloading it (xmlHttpRequest) but Back/Forward Buttons still work as usual?</p>
  
  <p>It's not about using <code>history.pushState()</code> methods. <code>PushState()</code> only changes URL-string but does nothing to get previous looking page after you click Back Button. So it's smth different.</p>
  
  <p>Here's my code and example.</p>
  
  <p>I have such site (look at the pic below). Header-div and Content-div. At the begining when you first time open it, the URL is <code>mysite.com/page1.php.</code> I want to change content in Content-div without reloading page. Just new info should appear in Content-div. And the URL should change to <code>mysite.com/page2.php</code>.</p>
  
  <p>Here's HTML-code.</p>
  
  <pre><code>&lt;div id="content"&gt;&lt;/div&gt;
  
  &lt;a href="" id="relaodLink"&gt;Reload Content&lt;/a&gt;
  </code></pre>
  
  <p>Here's JS-code to it.</p>
  
  <pre><code>document.getElementById("relaodLink").onclick = function() {
      var xmlHttp = new XMLHttpRequest();
  
      xmlHttp.open("GET", "page2.php", true);
      xmlHttp.send();
  
      xmlHttp.onreadystatechange = function() {
          if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status == 200) {
              document.getElementById("content").innerHTML = xmlHttp.responseText;
          }
      }
      return false;
  }
  </code></pre>
  
  <p>So Header should not reload after pressing <code>relaodLink</code>, just content in Content-div changes. And most important: URL should change like page was really reloaded. Back Button allows to go to <code>mysite.com/page1.php</code> and then Forward Button allows to go back to <code>mysite.com/page2.php</code> again. With <code>history.pushState()</code> methods it doesn't work. But in FB Back and Forward Buttons work fine. How to make it?</p>
  
  <p><a href="https://i.stack.imgur.com/w41BN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w41BN.jpg" alt="a busy cat"></a><br>
  <sub>(source: <a href="http://www.ljplus.ru/img4/a/_/a_ya_vishe/primer-xmlhttp_3.jpg" rel="nofollow noreferrer">ljplus.ru</a>)</sub>  </p>