当前位置:网站首页>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的查询部分 |
边栏推荐
- Solid state relay
- Matlab draws the statistical rose chart of wind speed and direction
- Why do server programs need to listen first
- Understanding of L1 regularization and L2 regularization [easy to understand]
- Station B collapsed. What did the developer responsible for the repair do that night?
- Import word document pictures blocking and non blocking IO operations
- Finish learning redis cluster solution at one go
- Lvs+kept highly available cluster
- Yyds dry goods inventory # solve the real problem of famous enterprises: cycle number comparison
- Time relay
猜你喜欢

基于简化的评分卡、Smote采样和随机森林的信贷违约预测

时间继电器

Read Plato farm's eplato and the reason for its high premium

How to customize logging of.Net6.0

Can JVM tuning be done with single core CPU and 1G memory?

高频继电器

Station B collapsed. If we were the developer responsible for the repair that night

Exception -exception

CMOS开关(二)_参数提取

ApacheSpark-命令执行(CVE-2022-33891) 漏洞复现
随机推荐
Polarization relay
dBm和Vpp以及Vpeak的关系
ThreadLocal principle and source code analysis (click in step by step, don't recite, learn ideas)
CMOS传输门原理及应用
Is log4j vulnerability still widespread?
Leetcode-199-right view of binary tree
Deploy dolphin scheduler high availability cluster based on rainbow
Temperature relay
C language output teaching calendar
How to use Fiddler for weak network testing
Huaneng Fujian company and Huawei digital energy deepen strategic cooperation and jointly build a low-carbon smart county
2022 2nd cyber edge cup cyber security competition Web
软件测试的就业前景到底怎么样?
Internal class (detailed explanation of four internal classes)
项目分析(哪些是it培训给不了)
Inertial navigation principle (VII) -imu error classification (II) -allan variance analysis method +imu test + calibration introduction
Live broadcast software app development, uniapp scroll view hidden scroll bar
【二叉树】统计二叉树中好节点的数目
SQL injection less26a (Boolean blind injection)
云原生微服务第三章之Haproxy+Keepalived