我的history.js有问题
https://github.com/browserstate/history.js/
第3170行的事件onload处于无限循环
此事件的用途是什么?什么会触发它?!
只有在 Chrome 中我才会遇到这个问题
/**
* Bind for Saving Store
*/
if ( sessionStorage ) {
// When the page is closed
History.onUnload = function(){ // <----- this is triggeren in a loop
// Prepare
var currentStore, item, currentStoreString;
// Fetch
try {
currentStore = JSON.parse(sessionStorage.getItem('History.store'))||{};
}
catch ( err ) {
currentStore = {};
}
最佳答案
在我评论了你的问题后,我很快就找到了解决方案。 History.js 报告了有关此行为的问题 here .
主要原因是 setInterval
调用,这是由于 IE8 的限制而存在的。代码中的问题是它适用于所有情况,而不仅仅是 IE8。
在主项目中的某个时间得到修复之前,可以通过编辑 History.js 第 #1992 行附近的代码来修复这种不必要的轮询。
// For Internet Explorer
if (History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 9) {
History.intervalList.push(setInterval(History.onUnload, History.options.storeInterval));
}
关于jquery - History.js 无限事件循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21504638/