Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there any way which doesn't break the back navigation button (since upon pressing back the JavaScript statement will execute again, causing an immediate change of location and jumping forward again in the history)?

I thought about checking whether history.forward is empty as a condition for changing the location, but I don't think you're allowed to do that check...

Alternatives such as meta refreshes and non-JavaScript solutions are cool ways to solve this, but for POST calls it remains an issue...



For POST you should use POST-redirect-GET pattern with status 303.

You can change URL in JS without creating history entry with location.replace().


You can use history.replaceState in newer browers to modify the URL in the address bar without affecting the history. It doesn't actually load the new page, though.

https://developer.mozilla.org/en/DOM/Manipulating_the_browse...


There is a javascript function that allows you to change the url, so you can change the url when the page changes (like infinite scroll), so that going to one url and back will land you on the page you left (I think it is pushState() ).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: