2

I have made several websites and web applications, and still not sure of what the behaviour of the browser's back button should be.

In some cases where AJAX and JavaScript technology is used, hitting the back button will render a page which is quite different to what the user left when he exited the page. I think that the user should find exactly what he was seeing, except if that is a one-time action, like buying an item, printing a page, downloading a file, etc., in such a case, the user would be rendered the same HTML and loaded DOM, but without, obviously, repeating the action, maybe with an indication.

Would that be a correct approach? I have seen questions about reloading the page after back button press, in order to clear all the built and modified DOM, but that would render a fresh page, which is not exactly what the user would expect.

1

Ideally your browser should always go back through the history of content shown on the page including content which has been added using AJAX. Now historically this has been difficult and has involved using hashtags in the URL and capturing the hashtag using javascript on page load and then re-initiating the AJAX call in question but since the inception of HTML5 this has been made a lot easier througb the use of the HTML5 History API. The API allows you to modify the websites URL without a full page refresh which is particularly useful for AJAX based page content.

For information on how to do it within your specific implementation take a look at http://www.w3schools.com/jsref/obj_history.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.