当前位置:网站首页>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^)\\\~~~
谢谢各位读者们啦(^_^)∠※
!!!
边栏推荐
猜你喜欢
【蓝桥杯选拔赛真题48】Scratch跳舞机游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
【实战技能】单片机bootloader的CANFD,I2C,SPI和串口方式更新APP视频教程(2022-08-01)
期货公司开户关注的关键点
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动画优化之传统引导层动画
An工具介绍之形状工具及渐变变形工具
软件测试自学还是报班好?
Tinymce plugins [Tinymce扩展插件集合]
The components of the basis of An animation movie clip animation between traditional filling
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
随机推荐
OpenCV 透视变换
层次分析法
leetcode 11. 盛最多水的容器
基于php旅游网站管理系统获取(php毕业设计)
Database basics one (MySQL) [easy to understand]
Image fusion GAN-FM study notes
Jmeter use
Image fusion SDDGAN article learning
An动画优化之补间形状与传统补间的优化
An动画基础之散件动画原理与形状提示点
leetcode16最接近的三数之和 (排序+ 双指针)
IDEA的模板(Templates)
Oracle is installed (system disk) and transferred from the system disk to the data disk
How does Filebeat maintain file state?
字节最爱问的智力题,你会几道?
When Nodejs installation depends on cpnm, the install shows Error: Cannot find module 'fs/promises'
汉源高科G8032标准ERPS环网交换机千兆4光10电工业以太网交换机环网+WEB管理+SNMP划VLAN
d写二进制
Autumn recruitment work
Golang sync.WaitGroup