当前位置:网站首页>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的查询部分 |
边栏推荐
- 【StoneDB故障诊断】系统资源瓶颈诊断
- MySQL series - database tables, queries, sorting, and data processing functions
- SQL injection less26a (Boolean blind injection)
- EC code introduction
- Alibaba Senior Software Testing Engineer recommends testers to learn -- Introduction to security testing
- A lock faster than read-write lock. Don't get to know it quickly
- 电磁继电器
- First knowledge of esp8266 (I) -- access point and wireless terminal mode
- 高频继电器
- What is eplato cast by Plato farm on elephant swap? Why is there a high premium?
猜你喜欢

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

Why do server programs need to listen first

Exception -exception

vs2019 release模式调试:此表达式有副作用,将不予计算。

leetcode15--三数之和

极化继电器

Monitor the running of server jar and restart script

Log4j 漏洞仍普遍存在,并持续造成影响

Implementation of arbitrary code execution based on.Net dynamic compilation technology

Simple use of enum
随机推荐
Leetcode-199-right view of binary tree
Seven lines of code crashed station B for three hours
【无标题】
Talk about MySQL transaction two-phase commit
温度继电器
8000字讲透OBSA原理与应用实践
一种比读写锁更快的锁,还不赶紧认识一下
What is the employment prospect of software testing?
视频直播源码,uni-app实现广告滚动条
基于简化的评分卡、Smote采样和随机森林的信贷违约预测
Nine days later, we are together to focus on the new development of audio and video and mystery technology
Cocos: simple application of ccpdistance function and the function of eyeball rotating in orbit with fingers
Matlab 绘制风速、风向统计玫瑰花图
MySQL data recovery process is based on binlog redolog undo
Reed relay
项目管理工具禅道
Station B collapsed. If we were the developer responsible for the repair that night
If demand splitting is as simple as cutting a cake | agile practice
Optocoupler relay
Mask automatic update description file (mask description file)