Get the number of local storage item for this domain:
var x = localStorage.length;
Try it Yourself »
The length property returns the number of items stored in the browsers Storage Object, for this particular domain..
The length property belongs to the Storage Object, which can be either a localStorage object or a sessionStorrage object.
Property | |||||
---|---|---|---|---|---|
length | 4 | 8 | 3.5 | 4 | 10.5 |
localStorage.length;
sessionStorage.length;
DOM Version: | Web Storage API |
---|---|
Return Value: | A Integer, representing the number of stored items |
The same example, but using session storage instead of local storage.
Get the number of session storage item for this domain:
var x = sessionStorage.length;
Try it Yourself »
Loop through each local storage item and display the names:
for (i = 0; i < localStorage.length; i++) {
x = localStorage.key(i);
document.getElementById("demo").innerHTML += x;
}
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!