这是我的代码:
if(typeof(Storage)!==undefined) {
// Web storage support
if(localStorage.hashes != "") {
var hashes = jQuery.parseJSON(localStorage.hashes);
for (var i = 0; i < hashes.length; i++) {
// Do stuff here
}
}
else {
var hashes = [];
}
}
else {
// No web storage support
}
我真的不知道发生了什么,但是当我第一次尝试从设备加载带有此代码的页面时,我的其余代码无法正常工作。但是,如果我将其注释掉,那么第一次访问该页面一切正常。然后我可以取消注释,重新加载页面,一切都会继续工作。这真的是我能描述的最好的情况。