I'm making a website that works on a single page. So when I click on a menu button it scrolls to the area I want with:
$('html, body').animate({scrollTop: $('#nomedoid').offset().top},Math.abs(0));
And at the same time I put the window.history.pushState:
window.history.pushState(null, 'blablabla', 'link');
It works as I expected, if I click the back button of the browser (or cell phone) the site goes back to the last page of the site, including scrolling to it.
The problem: There is now a "page" that opens on the site, enter a div in front of the site with addClass and also give the window.history.pushState:
$('.frente_site').addClass('frente_site_aparece');
window.history.pushState(null, 'blablabla', 'link-frente');
There you go back in the browser until the URL changes, but it does not removeClass in the class '.frente_site'. How could this happen? Am I doing the wrong thing?