本地存储在铬 [英] Local storage in chrome
问题描述
我有一个将字符串保存到本地存储的JavaScript代码,字符串大小为400000,
var dataURL = canvas .toDataURL( 图像/ JPG)的toString();
localStorage.setItem(dataURL,dataURL);
我从chrome中打开html文件,在一台计算机中, p>
未捕获QuotaExceededError:未能在
'Storage'上执行'setItem':设置'dataURL'的值超过配额。 / p>
在此计算机中,我允许保存字符串长度不超过100000个字符。
这两台电脑都有相同的版本35.0.1916.114 m
为什么?
I have a JavaScript code which save string to the Local storage, the string size is 400000, I open the html file from chrome, in one computer its OK in the other computer i get Uncaught QuotaExceededError: Failed to execute 'setItem' on
'Storage': Setting the value of 'dataURL' exceeded the quota. In this computer I allowed to save string length no more than 100000 chars.
Both computers have the same chrome's Version 35.0.1916.114 m
Why? rWhen your browser reaches to maximum limit it will throw this error
Failed to execute 'setItem' on 'Storage': Setting the value of '' exceeded the quota.
这篇关于本地存储在铬的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
在'Storage'上执行'setItem'失败:设置''的值超过配额。
您可以像这样处理它
try {var count = 100; var message =LocalStorageIsNOTFull; for(var i = 0; i <= count; count + 250){message + = message; localStorage.setItem(stringData,message);的console.log(localStorage的);的console.log(计数); }} catch(e){console.log(本地存储已满,请清空数据); //当localstorage存满时//你可以在这里处理错误或清空本地存储}
var dataURL = canvas.toDataURL("image/jpg").toString();
localStorage.setItem("dataURL", dataURL);
try {
var count = 100;
var message = "LocalStorageIsNOTFull";
for (var i = 0; i <= count; count + 250) {
message += message;
localStorage.setItem("stringData", message);
console.log(localStorage);
console.log(count);
}
}
catch (e) {
console.log("Local Storage is full, Please empty data");
// fires When localstorage gets full
// you can handle error here or empty the local storage
}