$(document).ready(function () {
$('#gnav a').click(function (e) {
e.preventDefault();
$('#contents').load(this.hash.substr(1) +'.php')
});
});
That is my jQuery cod开发者_JAVA技巧e that loads some content into a div via Ajax. How can I make use of the browser back button with that code?
Thanks!
You could use the HTML5 history APIs described at http://diveintohtml5.ep.io/history.html -- that gives you complete control of back/forward behaviour for your internal navigation.
There is a nice jquery plugin called BBQ http://benalman.com/projects/jquery-bbq-plugin/ Easy to use, documentation is on the page
Another plugin you should consider is JQuery Address. I used it on a project and found it pretty flexible.
Enables "Deep linking" so you can use it to fire ajax calls based on anchor/query string. http://www.asual.com/jquery/address/
精彩评论