小编Jos*_*son的帖子

前进按钮在 history.pushState 后不起作用

我已经找到了如何修复后退按钮,但前进按钮仍然无法修复。url 会改变,但页面不会重新加载,这就是我正在使用的:

$('.anchor .wrapper').css({
  'position': 'relative'
});

$('.slanted').css({
  'top': 0
});

// Do something after 1 second
$('.original-page').html('');
var href = '/mission.html'

console.log(href);
// $('#content-div').html('');

$('#content-div').load(href + ' #content-div');
$('html').scrollTop(0);
// loads content into a div with the ID content_div

// HISTORY.PUSHSTATE
history.pushState('', 'New URL: ' + href, href);
window.onpopstate = function(event) {
  location.reload();
};

//            response.headers['Vary'] = 'Accept';
//            window.onpopstate = function (event) {
//                alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
//                            location.reload();
//                        response.headers['Vary'] …
Run Code Online (Sandbox Code Playgroud)

html javascript ajax jquery pushstate

7
推荐指数
1
解决办法
4272
查看次数

标签 统计

ajax ×1

html ×1

javascript ×1

jquery ×1

pushstate ×1