如何显示localStorage的剩余空间?
我正在创建一个使用 localStorage 的网络应用程序。
我想显示如下内容: X % 的使用量超过 Y 兆字节
如何计算?
问候。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
IE 有一个专有属性“window.localStorage.remainingSpace”,它返回剩余空间(以字节为单位)。不幸的是,在任何其他浏览器中都找不到类似的功能。
http://msdn.microsoft.com/en-我们/library/cc197016(v=vs.85).aspx
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
我认为这将帮助您 计算 localStorage 空间的使用情况
没有办法向浏览器查询确切的信息
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