当我点击"返回"我fonud safari无休止地刷新页面。带有此代码的按钮
window.addEventListener('popstate', function() {
location.reload();
});
Chrome和IE很好。如何解决这个问题?
由于
答案 0 :(得分:0)
答案 1 :(得分:0)
这个黑客正在为我工作:/
https://gist.github.com/voku/854fef3b9a3fbf10624f
/**
* reload on history-back with "history.pushState" usage
*
* Necessary hack because WebKit fires a popstate event on document load
* https://code.google.com/p/chromium/issues/detail?id=63040
* https://bugs.webkit.org/process_bug.cgi
*/
$(window).bind('load', function() {
if (Modernizr.history) {
setTimeout(function() {
$(window).bind('popstate', function() {
location.reload();
});
}, 0);
}
});