I use window.history.pushState
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.
What I want is that pressing Back after closing the popup goes back to the previous page before opening the popup.
Home -> Page -> Popup 1 -> Popup 2 -> (Close popup) Page -> (Press back) Home (instead of Popup 2)