1

If the current url is /currentpage.html

and if I change the url on the browser

$('#newurl').click(function(){
     $.ajax({url:"newpage/index.html"});
});

How can I get the /currentpage.html page to reopen when the browser back button is clicked?

Bekki
  • 719
  • 2
  • 12
  • 20
  • Did you try to ave it in history? – MaxZoom Jul 20 '15 at 05:19
  • @MaxZoom you mean `window.history.go(-1)` ? I do not know how to make the browser back button do this? – Bekki Jul 20 '15 at 05:22
  • Yes, something like described [here](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history) – MaxZoom Jul 20 '15 at 05:25
  • @MaxZoom I've alredy gone through it. But was unable to figure it out. I also read that `replaceState()` was a better option but I couldn't put things together to make the browser back button do it. – Bekki Jul 20 '15 at 05:28
  • That code doesn't "change the url on the browser" (if that means what I think you mean). You are probably doing something that you aren't showing us. – RoToRa Jul 20 '15 at 08:09
  • Also what do you mean with "url is customized" in the title? That code doesn't do that either. – RoToRa Jul 20 '15 at 08:10

1 Answers1

0

My take on your question is that you want to save the AJAX requests in your history as well

There is now the HTML5 History API (pushState, popState) which deprecates the HTML4 hashchange functionality.

History.js provides cross-browser compatibility and an optional hashchange fallback for HTML4 browsers.

You might want to checkout this SO Question

Community
  • 1
  • 1
Abhinav
  • 8,028
  • 12
  • 48
  • 89