打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Window.localStorage

The localStorage property allows you to access a local Storage object. localStorage is similar to sessionStorage. The only difference is that, while data stored in localStorage has no expiration time, data stored in sessionStorage gets cleared when the browsing session ends—that is, when the browser is closed.

Syntax

myStorage = localStorage;

Value

A Storage object.

Example

The following snippet accesses the current domain's local Storage object and adds a data item to it using Storage.setItem().

localStorage.setItem('myCat', 'Tom');

Note: Please refer to the Using the Web Storage API article for a full example.

Specifications

Specification Status Comment
Web Storage (Second edition)
The definition of 'localStorage' in that specification.
Recommendation  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
localStorage 4 3.5 8 10.50 4
sessionStorage 5 2 8 10.50 4

All browsers have varying capacity levels for both localStorage and sessionStorage. Here is a detailed rundown of all the storage capacities for various browsers.

Note: Starting with iOS 5.1, Safari Mobile stores localStorage data in the cache folder, which is subject to occasional clean up, at the behest of the OS, typically if space is short. Safari Mobile's Private Browsing mode also prevents writing to localStorage entirely.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
四种有能力取代Cookies的客户端Web存储方案
Future Mobile Phones Could Come with 2 Terabyte Memory Cards
What is M.2 SSD?
客户端缓存和服务器端缓存
Android WebView缓存分析
16天记住7000考研词汇:第5天
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服