title: How to add a page to a new tab's history so that the back button reloads that page?
body: <p>From "Page A" I can open a new tab for "Page B" (the current, "old" tab then navigates to another page that is not particularly relevant here). But I need the new tab to have "Page A" in its history so that pushing the browser's back button returns to that page--unfortunately I am unable to do that.</p>
  
  <p>Here is what I'm trying:</p>
  
  <pre><code>var pageA = window.location.href;
  var newTab = window.open("about:blank");
      window.setTimeout(function(){
          newTab.location.href = url;
          newTab.history.replaceState({fromBackClick: true}, "page1", pageA);
          newTab.history.pushState({fromBackClick: true}, "page2", url);
          newTab.setTimeout(function() {
              newTab.onpopstate = function () {
                  //newTab.location.href = pageA; /* alternative to next line */
                  newTab.location.reload(true);
                  return true;
              };
          }, 100);
          window.location.href = new_url;
      }, 100);
  </code></pre>
  
  <p>Please note that <code>url</code> and <code>new_url</code> are parameters passed to the function of which this code is part.</p>
  
  <p>What happens is that the new tab opens fine with the contents of "Page B", and when you click "back" the "Page A" url appears in the address bar. Unfortunately though the apparent URL changes, the browser doesn't actually navigate back to the actual "Page A" page. For some reason the <code>onpopstate</code> call-back never fires (even if I comment out the change of href for the current tab).</p>
  
  <p>Does anyone know how to get so that hitting back actually goes back to the URL in the address bar?</p>
  
  <h1>Edit</h1>
  
  <p>I know this is possible because Kayak.com does it in Chrome if you search with some of the partner checkboxes checked.</p>