I’m using
var integer = window.location.hash.match(/\d+/) | 0;
alert(integer);
to get id from the hash url but when i use back button after changing the url after ajax call.
It doesn’t reflect any change, basically page remains in same state and only the url changes.
so, what i want to know is that how to change the content when i use back button.
Or simply show the integer in alert box when i use back button that’s it.
e.g.
http://test.php/#1
show 1 when i get to that page using back button
http://test.php#2
show 2 when i get to that page using back button
http://test.php
show 0 when i get to that page using back button
You need to catch the
window.onhashchangeevent, or use HTML5’shistory.pushState()methods.Or just use the jQuery history plugin.