Is there a way using Jquery to detect the back button being pressed cross browsers
jQuery Address provides strong cross-browser support for browser history and Ajax crawling:
http://www.asual.com/jquery/address
http://github.com/asual/jquery-address
Greetings
UPDATE:
you can find a good sample right here:
http://jsfiddle.net/5L6Ur/10/
some code in short:
$(function() {
$('a').click(function(e) {
e.preventDefault();
$.address.value($(this).attr('href'));
});
var changecount = 0;
$.address.change(function(e) {
if (typeof e !== 'function') {
$('span').html(changecount++);
}
});
});
You should:
- Set
location.hash
when page state changes. - When
location.hash
changed by user (for example, by pressing back button) render appropriate page contents.