相关疑难解决方法(0)

使用pushState()/ onpopstate时,页面不会通过'back'重新加载

我正在使用AJAX刷新一些页面,因此使用以下代码更新历史记录 -

/** Update the page history */
var pushState_object = {
    ajax_string: ajax_string,
    security: security,
};
window.history.pushState(pushState_object, title, permalink);
Run Code Online (Sandbox Code Playgroud)

然后我在页面加载时调用这个onPopState函数 -

window.onpopstate = function(e){
    if(window.history.state !== null){
        initiate_load_updated_page(window.history.state.ajax_string, window.history.state.security, 0)
    }
}
Run Code Online (Sandbox Code Playgroud)

虽然在从通过AJAX生成内容的页面转到以通常方式加载的页面时使用后退按钮,但我遇到了一些问题.URL将更改,但页面将不会重新加载.再次点击返回会带我到页面,正如我所料,然后前进工作正常 - 这只是后退按钮不起作用的一种情况.

这里的任何建议将不胜感激.

javascript html5 pushstate

17
推荐指数
1
解决办法
1万
查看次数

标签 统计

html5 ×1

javascript ×1

pushstate ×1