当前位置:网站首页>sessionStorage of BOM series
sessionStorage of BOM series
2022-08-03 13:16:00 【old__L】
目录
1、属性
1.1、length
1.1.1、概述
length 是 sessionStorage 接口的只读属性,返回一个整数,表示存储在 sessionStorage data items in the object(data items)数量.
1.1.2、语法
var aLength = sessionStorage.length;
1.1.3、返回值
一个整数
2、方法
2.1、存储数据
2.1.1、概述
sessionStorage 接口的 setItem() 方法,Accepts a key and value as parameters,will add the key name to the given sessionStorage 对象中,If the key name already exists,则更新其对应的值.
2.1.2、语法
sessionStorage.setItem(keyName, keyValue);
2.1.3、参数
- keyName
一个 DOMString,Indicates the key name to be created or updated.
- keyValue
一个 DOMString,Represents the value corresponding to the key name to be created or updated.
2.1.4、返回值
undefined
2.1.5、异常
in the case of a full storage,调用 setItem() 可能会抛出异常.Developers should always catch setItem() 可能抛出的异常.
2.2、获取数据
2.2.1、概述
getItem() 作为 sessionStorage 接口的方法,accepts a key name(key name)作为参数,and returns the value corresponding to the key name(key’s value).
2.2.2、语法
var aValue = sessionStorage.getItem(keyName);
2.2.3、参数
- keyName
One containing the key name DOMString.
2.2.4、返回值
一个 DOMString,键名对应的值.If the key name does not exist in the store,则返回 null.
2.3、删除数据
2.3.1、概述
sessionStorage 接口的 removeItem() 方法,accepts a key name作为参数,会从给定的 sessionStorage Delete the key name from the object(如果存在). If there is no item matching the given key name,then this method will do nothing.
2.3.2、语法
sessionStorage.removeItem(keyName);
2.3.3、参数
- keyName
一个 DOMString,i.e. the name of the key you want to remove.
2.3.4、返回值
无
2.4、清空数据(所有都清除掉)
2.4.1、概述
clear() 是 sessionStorage 接口的一个方法,Call it to clear all key values in the storage object.
2.4.2、语法
sessionStorage.clear();
2.4.3、参数
无
2.4.4、返回值
无
2.5、键
2.5.1、概述
key() 作为 sessionStorage 接口的方法,接受一个数值 n 作为参数,Returns the stored object No n 个数据项的键名.The order in which keys are stored is defined by the user agent,So try not to rely on this method as much as possible.
2.5.2、语法
var aKeyName = sessionStorage.key(key);
2.5.3、参数
- key
一个整数,Indicates the key name index to get.
2.5.4、返回值
One containing the key name DOMString.
后记
如果你感觉文章不咋地
//(ㄒoㄒ)//,就在评论处留言,作者继续改进;o_O???
如果你觉得该文章有一点点用处,可以给作者点个赞;\\*^o^*//
如果你想要和作者一起进步,可以微信扫描二维码,关注前端老L;~~~///(^v^)\\\~~~
谢谢各位读者们啦(^_^)∠※!!!

边栏推荐
- Golang 字典 map
- Using the Work Queue Manager (4)
- Redis connection pool tool class
- 软件测试面试(四)
- 技术分享 | 接口自动化测试如何搞定 json 响应断言?
- IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons
- 基于php志愿者服务平台管理系统获取(php毕业设计)
- [Deep Learning] Overview of Efficient and Lightweight Semantic Segmentation
- The Yangtze river commercial Banks to the interview
- Golang Mutex
猜你喜欢

How to disable software from running in the background in Windows 11?How to prevent apps from running in the background in Windows 11

An动画基础之按钮动画与基础代码相结合

An工具介绍之钢笔工具、铅笔工具与画笔工具

漫画:怎么证明sleep不释放锁,而wait释放锁?

An introduction to basic tools for selecting line tools (package church)

技术分享 | 接口自动化测试如何搞定 json 响应断言?

YOLOv5 training data prompts No labels found, with_suffix is used, WARNING: Ignoring corrupted image and/or label appears during yolov5 training

IronOS, an open source system for portable soldering irons, supports a variety of portable DC, QC, PD powered soldering irons, and supports all standard functions of smart soldering irons

An animation optimization of shape tween and optimization of traditional tweening

Image fusion GAN-FM study notes
随机推荐
可重入锁详解(什么是可重入)
An introduction to 3D tools
Sogou news-数据集
15. PARTITIONS「建议收藏」
类和对象(中上)
Secure Custom Web Application Login
An introduction to the pen tool, pencil tool and brush tool
使用工作队列管理器(三)
An工具介绍之形状工具及渐变变形工具
Blog records life
An动画基础之元件的影片剪辑动画与传统补间
How to disable software from running in the background in Windows 11?How to prevent apps from running in the background in Windows 11
HCIP-第十二天-MPLS+VNP
Redis连接池工具类
4年工作经验,多线程间的5种通信方式都说不出来,你信吗?
基于php志愿者服务平台管理系统获取(php毕业设计)
浅谈低代码平台远程组件加载方案
Image fusion SDDGAN article learning
使用 %Status 值
长江商业银行面试