我正在尝试使用 history.pushState
通过 ajax 加载页面并成功加载页面,但在这种情况下后退按钮不起作用。请在下面检查我的代码:
function processAjaxData(response, urlPath){
document.write(response)
document.title = '';
window.history.pushState({"html":response,"pageTitle":''},"", urlPath);
}
$('#apply_loader').click(function(e){
var nextPage = $(this).attr('href');
$.get(nextPage, // url
function (data, textStatus, jqXHR) { // success callback
processAjaxData(data,nextPage);
}
);
});
我正在尝试使用下面的 popstate
来识别后退按钮点击。
$(window).on('popstate', function(event) {
console.log('asd');
location.reload();
});