1
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');
Works as I expected, if I click the back button of the browser (or mobile) the site goes back to the last "page" of the site, including scrolling (scroll) for it.
THE PROBLEM: There is now a "page" that opens over the site, enters a div in front of the site with addClass and also gives the window.history.pushState:
$('.frente_site').addClass('frente_site_aparece');
window.history.pushState(null, 'blablabla', 'link-frente');
Then if I go back in the browser the URL changes, but it does not remove it in class '.frente_site'. Would you be able to make it happen? I’m doing it wrong?
What exactly are you changing in the url? The hash? ex:
www.exemplo.com#div1
,www.exemplo.com#div2
etc....?– Miguel
No, I switch from www.site.com.br to www.site.com.br/link-front
– caiocafardo