4

I'm creating a webapp which uses the localStorage.

I would like to show something like: X % is used over Y Megabytes

How to calculate that?

Regards.

Syl
  • 2,232
  • 8
  • 34
  • 45

2 Answers2

2

IE has a proprietary propery "window.localStorage.remainingSpace" which returns the remaining space in bytes. Unfortunately can't find similar functionality in any of the other browsers.

http://msdn.microsoft.com/en-us/library/cc197016(v=vs.85).aspx

Roy Paterson
  • 863
  • 9
  • 17
1

I think that this will help you out Calculating usage of localStorage space

There is no way to query to browser for that exact information

Community
  • 1
  • 1
JoshStrange
  • 1,121
  • 1
  • 7
  • 22
  • 2
    What they are doing in that answer is constantly writing to LocalStorage until it fills up, that way they know how much space there is – JoshStrange Dec 20 '11 at 14:35