I'm writing a simple photo album app using ASP.NET Ajax.
The app uses async Ajax calls to pre-load the next photo in the album, without changing the URL in the browser.
The problem is that when the user clicks the back button in the browser, the app doesn't go back to the previous photo, instead, it navigates to the home page of the application.
Is there a way to trick the browser into adding each Ajax call to the browsing history?
AJAX: Synchronous or Asynchronous Synchronously, in which the script stops and waits for the server to send back a reply before continuing. Asynchronously, in which the script allows the page to continue to be processed and handles the reply if and when it arrives.
Ajax is supported in all modern browsers. We suggest using the following browsers: Google Chrome. Mozilla Firefox.
Update: 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.
The answer for this question will be more or less the same as my answers for these questions:
In summary, you'll definitely want to check out these two projects which explain the whole hashchange process and adding ajax to the mix:
jQuery History (using hashes to manage your pages state and bind to changes to update your page).
jQuery Ajaxy (ajax extension for jQuery History, to allow for complete ajax websites while being completely unobtrusive and gracefully degradable).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With