Reputation: 193
Need to implement ajax navigation without any page reload I'm writing html to ajax container div. Is there any solution to handle browser back and forward events. Also adding to a bookmark? I need to cover all browser including IE 8 and higher. Thanks
Upvotes: 1
Views: 791
Reputation: 780698
The browser history is normally only updated when the browser loads a new page. AJAX doesn't replace the page, so the history is not changed.
HTML5 adds an API to allow Javascript to update the history directly, the history.pushState()
and history.replaceState()
methods. Your AJAX code should be able to use pushState()
to add the old URL to the browser history, so the back button will work. See the HTML5 spec for the gory details.
Since this is relatively new, older browsers won't support it. You could use the jQuery BBQ Plugin for cross-browser applications.
Upvotes: 2