Hello, there is a popUp window and that's when the URL opens with the help of

history.pushState(data,title, url); 

When I press the back button, the URL changes. it becomes as before, so I would also like to close the window, but how can I catch the event on the button back and forth?

 window.onhashchange = function() { var hash = window.location.hash.substring(1); alert(hash); 

this one didn't work. In Google I can not find any materials: (

1 answer 1

Try to implement through this function:

 window.onpopstate = function( e ) { //Ваши действия }