Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript show localstorage size

 function getUsedLocalStorageSpace(){
        var allStrings = '';
        for(var key in window.localStorage){
            if(window.localStorage.hasOwnProperty(key)){
                allStrings += window.localStorage[key];
            }
        }
        return allStrings ? 3 + ((allStrings.length*16)/(8*1024)) + ' KB' : 'Empty (0 KB)';
 };
 getUsedLocalStorageSpace();//
 
PREVIOUS NEXT
Tagged: #javascript #show #localstorage #size
ADD COMMENT
Topic
Name
7+2 =