当前位置:网站首页>Browser Storage WebStorage
Browser Storage WebStorage
2022-08-05 06:20:00 【-Little Dragon Man】
介绍
浏览器存储WebStorage包括 LocalStorage 和 SessionStorage,The storage content size is generally in5M左右.
如何使用
浏览器通过Window.localStorage 和 Window.sessionStorage属性来实现本地存储机制,It can be omitted in actual useWindow.
API使用
LocalStorage 和 SessionStorage的APIThe method name usage is the same,added respectively、获取、删除、Empty four methods,See the example below for the method name and how to use it:
//新增WebStorage: setItem(key,val)
localStorage.setItem("a", "123");
localStorage.setItem("b", "456");
localStorage.setItem("c", "789");
sessionStorage.setItem("a", "123");
sessionStorage.setItem("b", "456");
sessionStorage.setItem("c", "789");
//获取WebStorage: getItem(key)
localStorage.getItem("a");
sessionStorage.getItem("a");
//删除WebStorage: removeItem(key)
localStorage.removeItem("c");
sessionStorage.removeItem("c");
//清空WebStorage: removeItem(key)
localStorage.clear();
sessionStorage.clear();
LocalStorage 和 SessionStorage区别
Also stored in the browserWebStorage,LocalStorage 和 SessionStorage使用的API相同,But the actual usage scenarios are different:
LocalStorage
使用localStorageSaved data is retained for a long time,Even if you close the browser next time you reopen the page,The saved data will still not be cleared,If it needs to be cleared, it must be cleared manually.And the same source in the same browser(window.location.origin)All other pages are accessible localStorage 访问到,Of course between source and source localStorage 是不能互相访问的.i.e. between each source localStorage 是相互独立的.SessionStorage
使用sessionStorageThe saved data will remain only for the current page,That is, the page session level,When closing the browser or closing the tabsessionStorageSaved data will be cleared,And in the same browser even the same source,Other pages cannot be sharedsessionStorage保存的数据.
边栏推荐
- Servlet跳转到JSP页面,转发和重定向
- Hugo builds a personal blog
- Spark source code-task submission process-6.2-sparkContext initialization-TaskScheduler task scheduler
- LinkSLA insists that users come first and creates a sustainable operation and maintenance service plan
- markdown编辑器模板
- [ingress]-ingress使用tcp端口暴露服务
- ACL 和NAT
- 网络布线与数制转换
- The spark operator - repartition operator
- NAT实验
猜你喜欢
随机推荐
NIO works is analysed
Small example of regular expression--remove spaces in the middle and on both sides of the string
实力卷王LinkSLA,实现运维工程师快乐摸鱼
VLAN介绍与实验
js动态获取屏幕宽高度
vim的三种模式
User and user group management, file permission management
Getting Started Doc 08 Conditional Plugins
Three modes of vim
千亿IT运维市场,产品要凭实力说话
markdown编辑器模板
智能运维会取代人工运维吗?
IP packet format (ICMP protocol and ARP protocol)
King power volume LinkSLA, realize operations engineer is happy fishing
请问下通过flink sql读取hologres 的两张表的 binlog,然后如何进行join?
IP数据包格式(ICMP协议与ARP协议)
Image compression failure problem
用户和用户组管理、文件权限管理
ACL 和NAT
Account and Permission Management