Ejemplo en funcionamiento:
http://pruebajquery.site50.net/#!:page/about.html
js:
Código:
mikehove // call init $(init); function init() { ajax_page_handler(); page_load($(window.location).attr("hash")); // goto first page if #!: is available } function page_load($href) { if($href != undefined && $href.substring(0, 3) == '#!:') { $('#content').load($href.substring(3)); // replace body the #content with loaded html $('html, body').animate({scrollTop:0}, 'slow'); // bonus } } /** * This method load #content on every url hash change * * @return */ function ajax_page_handler() { $(window).bind('hashchange', function () { $href = $(window.location).attr("hash"); page_load($href); }); // this allow you to reload by clicking the same link //a[href^="#/" $('a[href^="#/"]').live('click', function() { // $('a[href^="#/"]').live('click', function() { $curhref = $(window.location).attr("hash"); $href = $(this).attr('href'); if($curhref == $href) { page_load($href); } }); }