Возможно, вы захотите проверить проект jQuery History:
http://www.balupton.com/projects/jquery-history
Это немного более полнофункциональный и простой в реализации, чем другие, плюс поддержка, если она фантастическая. Для этого также имеется полнофункциональное расширение AJAX, позволяющее легко интегрировать запросы Ajax в ваши состояния / хэши, чтобы превратить ваш веб-сайт в полнофункциональное приложение Web 2.0:
http://www.balupton.com/projects/jquery-ajaxy
Вот пример использования jQuery History (взятый с демонстрационного сайта):
// Bind a handler for ALL hash/state changes
$.History.bind(function(state){
// Update the current element to indicate which state we are now on
$current.text('Our current state is: ['+state+']');
// Update the page"s title with our current state on the end
document.title = document_title + ' | ' + state;
});
// Bind a handler for state: apricots
$.History.bind('/apricots',function(state){
// Update Menu
updateMenu(state);
// Show apricots tab, hide the other tabs
$tabs.hide();
$apricots.stop(true,true).fadeIn(200);
});
И пример jQuery Ajaxy (взятый с демонстрационного сайта):
'page': {
selector: '.ajaxy-page',
matches: /^\/pages\/?/,
request: function(){
// Log what is happening
window.console.debug('$.Ajaxy.configure.Controllers.page.request', [this,arguments]);
// Adjust Menu
$menu.children('.active').removeClass('active');
// Hide Content
$content.stop(true,true).fadeOut(400);
// Return true
return true;
},
response: function(){
// Prepare
var Ajaxy = $.Ajaxy; var data = this.State.Response.data; var state = this.state;
// Log what is happening
window.console.debug('$.Ajaxy.configure.Controllers.page.response', [this,arguments], data, state);
// Adjust Menu
$menu.children(':has(a[href*="'+state+'"])').addClass('active').siblings('.active').removeClass('active');
// Show Content
var Action = this;
$content.html(data.content).fadeIn(400,function(){
Action.documentReady($content);
});
// Return true
return true;
И если вы когда-нибудь захотите получить параметры строки запроса (например, yoursite/page.html#page1?a.b=1&a.c=2
), вы можете просто использовать:
$.History.bind(function(state){
var params = state.queryStringToJSON(); // would give you back {a:{b:1,c:2}}
}
Так что ознакомьтесь с этими демонстрационными ссылками, чтобы увидеть их в действии, и узнать все подробности установки и использования.