![](/img/trans.png)
[英]Back button is not working when using history.pushState() in ReactJs
[英]Back Button not work when load page using history.pushState in JS
我正在尝试通过 ajax 加载页面,并成功加载history.pushState
和页面,但在这种情况下后退按钮不起作用。 请在下面检查我的代码:
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();
});
也许为时已晚,但也许这会解决问题:
而不是 location.reload(),尝试:
window.location = location.href
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.