Переход между страницами без перезагрузки
Здравствуйте, недавно наткнулся на такую вот интересную штуку
http://codyhouse.co/gem/3d-bold-navigation/ Так вот, у этих ребят происходит замена информации содержащейся между тегами <section></section> при переходе по ссылке. Адрес страницы с которой был совершен переход не меняется. Отсюда возникает вопрос, как модифицировать этот код, чтобы при такой смене страниц менялся и адрес? $('.cd-nav li').on('click', function(event){ event.preventDefault(); var target = $(this), //detect which section user has chosen sectionTarget = target.data('menu'); if( !target.hasClass('cd-selected') ) { //if user has selected a section different from the one alredy visible //update the navigation -> assign the .cd-selected class to the selected item target.addClass('cd-selected').siblings('.cd-selected').removeClass('cd-selected'); //load the new section loadNewContent(sectionTarget); } else { // otherwise close navigation toggleNav(false); } }); function loadNewContent(newSection) {//тут как раз и вылавливается нужная инфа со страницы, на которую переходят, а как связать newSection с ссылкой на конкретную с траницу я не знаю((( //create a new section element and insert it into the DOM var section = $('<section class="cd-section '+newSection+'"></section>').appendTo($('main')); //load the new content from the proper html file section.load(newSection+'.html .cd-section > *', function(event){ //add the .cd-selected to the new section element -> it will cover the old one section.addClass('cd-selected').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ //close navigation toggleNav(false); }); section.prev('.cd-selected').removeClass('cd-selected'); }); $('main').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function(){ //once the navigation is closed, remove the old section from the DOM section.prev('.cd-section').remove(); }); if( $('.no-csstransitions').length > 0 ) { //detect if browser supports transitions toggleNav(false); section.prev('.cd-section').remove(); } } |
sas135,
window.history.pushState смотри |
Часовой пояс GMT +3, время: 02:46. |