localStorage 用于跨多個(gè)會(huì)話保存信息。它的最大大小為 5MB。
示例
您可以嘗試運(yùn)行以下代碼片段來(lái)檢查分配的大小 –
var sum = 0; // loop for size for(var i in localStorage) { var amount = (localStorage[i].length * 2) / 1024 / 1024; sum += amount; document.write( i + " = " + amount.toFixed(2) + " MB"); } document.write( "Total = " + sum.toFixed(2) + " MB");
登錄后復(fù)制
以上就是如何在HTML中找到localStorage的大小?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!