我试图在没有重新加载的情况下修改页面中的内容.目前我的代码是:
window.onpopstate = function(event){
// Ajax Request the Page and replace content with new content
};
Run Code Online (Sandbox Code Playgroud)
这在我按下状态然后触发popstate事件时有效,但是如果我按下浏览器中的后退按钮它会导航到url而不是调用onpopstate事件.如何阻止页面刷新并使用我的ajax调用更新页面?
编辑:我正在尝试使用pushState和popstate进行更新.我希望保持我的网址免费.