title: Go back to first state after window.history.pushState
body: <p>I use <code>window.history.pushState</code> to change the current URL when I open a popup on my page, which works well and is very convenient. Inside the popup I can go to other URLs. The problem is when I close the popup i use pushState again with the first URL, but if press back, it opens the popup again.</p>
  
  <p>What I want is that pressing Back after closing the popup goes back to the previous page before opening the popup.</p>
  
  <p>Home -> Page -> Popup 1 -> Popup 2 -> (Close popup) Page -> (Press back) Home (instead of Popup 2)</p>