Я смотрю демонстрацию, сделанную Codyhouse ( article | demo ), которая использует loadNewContent () для ввода содержимого из другого HTML-файла. Все работает отлично, однако, URL остается тем же, всегда как /index.html.
Я настраивал JS, чтобы попытаться сделать так, чтобы URL страницы обновлялся вместе с контентом, но безуспешно. Я пытался использовать replace (), но продолжаю зацикливаться ... или удаляю некоторые фрагменты кода, и это не работает вообще.
Есть какие-нибудь идеи относительно того, по какому пути я должен идти, чтобы сделать эту работу? Я хочу, чтобы он работал как есть, но если вы нажмете «О программе», я хочу, чтобы URL страницы был /about.html и т. Д.
function loadNewContent(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();
}
Я знаком с JS, но не разработчик ... так что любая помощь с благодарностью приветствуется !!