当前位置:网站首页>Window localStorage 属性和Location 对象
Window localStorage 属性和Location 对象
2022-07-27 19:35:00 【zsdxgogo】
Window localStorage 属性
使用 localStorage 创建一个本地存储的 name/value 对,name="lastname" value="Smith", 然后检索 "lastname" 的值,并插入到 id="result" 的元素上:
// 存储
localStorage.setItem("lastname", "Smith");
// 检索
document.getElementById("result").innerHTML = localStorage.getItem("lastname");语法
window.localStorage
保存数据语法:
localStorage.setItem("key", "value");读取数据语法:
var lastname = localStorage.getItem("key");删除数据语法:
localStorage.removeItem("key");Location 对象
Location 对象包含有关当前 URL 的信息。
Location 对象是 window 对象的一部分,可通过 window.location.xxx 格式的相关属性对其进行访问。
注意: 没有应用于Location对象的公开标准,不过所有浏览器都支持该对象。
Location 对象属性
| 属性 | 描述 |
|---|---|
| hash | 返回一个URL的锚部分 |
| host | 返回一个URL的主机名和端口 |
| hostname | 返回URL的主机名 |
| href | 返回完整的URL |
| pathname | 返回的URL路径名。 |
| port | 返回一个URL服务器使用的端口号 |
| protocol | 返回一个URL协议 |
| search | 返回一个URL的查询部分 |
边栏推荐
- Matlab draws the statistical rose chart of wind speed and direction
- Vs2019 release mode debugging: this expression has side effects and will not be evaluated.
- Station B collapsed. If we were the developer responsible for the repair that night
- @Can component be used on the same class as @bean?
- 一种比读写锁更快的锁,还不赶紧认识一下
- 极化继电器
- Leetcode-309- best time to buy and sell stocks, including freezing period
- 温度继电器
- How to buy stocks on mobile phones? Is it safe to open an account
- B站崩了,如果我们是那晚负责修复的开发人员
猜你喜欢

SQL注入 Less29(参数污染绕过WAF)

CMOS开关(二)_参数提取

@Can component be used on the same class as @bean?

8000 word explanation of OBSA principle and application practice

固体继电器

Interview question: what are the functions of fail safe mechanism and fail fast mechanism

If demand splitting is as simple as cutting a cake | agile practice

时间继电器

每条你收藏的资讯背后,都离不开TA
![[question 22] dungeons and Warriors (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)](/img/64/70fa9f47836e07dd41d9e283e50adb.jpg)
[question 22] dungeons and Warriors (Beijing Institute of Technology / Beijing Institute of Technology / programming methods and practice / primary school)
随机推荐
CMOS传输门原理及应用
视频直播源码,uni-app实现广告滚动条
Cocos: simple application of ccpdistance function and the function of eyeball rotating in orbit with fingers
Apachespark command execution (cve-2022-33891) vulnerability recurrence
Credit default prediction based on simplified scorecard, smote sampling and random forest
Mask automatic update description file (mask description file)
【二叉树】统计二叉树中好节点的数目
Why do server programs need to listen first
光藕继电器
Read Plato farm's eplato and the reason for its high premium
[Marine Science] climate indices data set
8000 word explanation of OBSA principle and application practice
Leetcode-39-total number of combinations
Regular expression exercise
MySQL series - database tables, queries, sorting, and data processing functions
How to learn object Defineproperty | an article takes you to quickly learn
项目管理工具禅道
It seems to be a bug of thread pool, but I think the source code design is unreasonable.
Interview questions that big companies need to prepare
Excel only wants to visualize charts and make data move? Yes, come and watch (with a large number of templates to download)