Aleks
Aleks

Reputation: 3966

How to stay on the same page when clicking the browser back button

enter image description here

I have 2 div's, with red color shown on the picture.

When loaded Div1 is shown and Div2 is hidden.

Div1 has 4 divs in it with 4 onclick events which call ajax and hide div1 and show the second one with the loaded data.

When clicking the browser back button it takes me one page back and i want the page to get back to the default position with the div1 visible and div2 hidden.

How can i do it?

Upvotes: 0

Views: 5943

Answers (1)

kalpaitch
kalpaitch

Reputation: 5271

Use the history push state in html5 - https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history

There is also a js script somewhere to default to hashbangs in browsers that don't support the push state.

Upvotes: 3

Related Questions