mirror of
https://github.com/CajunAvenger/cajunavenger.github.io.git
synced 2026-03-21 17:34:16 -05:00
41 lines
968 B
HTML
41 lines
968 B
HTML
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
localStorage limit in your Browser is
|
|
<span id="size">...</span> KBs.
|
|
</div>
|
|
<script>
|
|
//this script is to find the size of localStorage
|
|
|
|
function func1(num)
|
|
{
|
|
return new Array((num * 1024) + 1).join('a')
|
|
}
|
|
|
|
// Determine the size of localStorage if it's not set
|
|
|
|
if (!localStorage.getItem('size')) {
|
|
var i = 0;
|
|
try {
|
|
// Test up to 10 MB
|
|
for (i = 0; i <= 10000; i += 250) {
|
|
localStorage.setItem('test', func1(i));
|
|
}
|
|
} catch (e) {
|
|
localStorage.removeItem('test');
|
|
localStorage.setItem('size', i ? i - 250 : 0);
|
|
}
|
|
}
|
|
|
|
// when window is loaded this function is
|
|
// called and the size of localStorage is calculated
|
|
window.onload = function calculate(){
|
|
var el = document.getElementById('size');
|
|
el.innerHTML = localStorage.getItem('size');
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |