Reputation: 10564
According to many answers on StackOverflow with location.replace(URL)
you could redirect your user while keeping the page in the back button history.
I'd like to do the opposite, so I'm using location.href = URL
but I'm still experiencing the correct working of the back button: why is this?
Also, using location.replace()
in Chrome and IE10 seems to leave the back button intact as well. Please note that I'm not redirecting with location.replace("http://...")
but with location.replace("/page.html")
I want to redirect my user from a page to a configuration wizard, while inside the wizard the user should not be able to go back and forth between the pages: instead, pressing "back" should redirect it to the original page, outside the wizard.
One solution would be to load the pages of the wizard via AJAX and inject them with .html()
. We've already developed most of our web app pages this way but for this particular part the AJAX solution has been neglected by server side developers (go figure!).
What can I do?
Upvotes: 2
Views: 7190
Reputation: 26143
You've got them the wrong way round. location.replace
replaces the current page in the browser history. location.href
advances to the page.
See here...
https://developer.mozilla.org/en-US/docs/Web/API/window.location
Upvotes: 8