I have a little problem with the history.pushstate event. I configured it so that the URL of the page is the actual URL of the page loaded via AJAX, and this works fine.
I realized that it should automatically create a story by loading previously loaded pages. an unhappy hat does not happen, and when I press the back button, the URL changes, but not the page. Could you help me? Here is my simplified code:
function hijackLinks() {
$('a').live("click", function (e) {
e.preventDefault();
loadPage(e.target.href);
direction = $(this).attr('class');
});
}
function loadPage(url) {
if (url === undefined) {
$('body').load('url', 'header:first,#content,footer', hijackLinks);
} else {
$.get(url, function (data) {
$('body').append(data);
window.history.pushState(url, url, url);
if (direction === "leftnav") {
}
if (direction !== "leftnav") {
}
setTimeout(function () {
},1000);
});
}
}
$(document).ready(function () {
loadPage();
});
source
share