当前位置:网站首页>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的查询部分 |
边栏推荐
- STM32项目分享---MQTT智能门禁系统(含APP控制)
- 一口气学完 Redis 集群方案
- Leetcode15 -- sum of three numbers
- Interview questions that big companies need to prepare
- ThreadLocal principle and source code analysis (click in step by step, don't recite, learn ideas)
- Encapsulate an array into a class
- vs2019 release模式调试:此表达式有副作用,将不予计算。
- Behind every piece of information you collect, you can't live without TA
- 高频继电器
- Internal class (detailed explanation of four internal classes)
猜你喜欢

SQL注入 Less26a(布尔盲注)

How to deal with high concurrency deadlock?

Reed relay

It's too voluminous. A company has completely opened its core system (smart system) that has been operating for many years

Leetcode15 -- sum of three numbers

Solid state relay

Regular expression exercise

Memo mode - unity

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

CMOS开关(二)_参数提取
随机推荐
Leetcode 301. delete invalid parentheses
MySQL series - database tables, queries, sorting, and data processing functions
Leetcode-152- product maximum subarray
8000 word explanation of OBSA principle and application practice
Interview questions that big companies need to prepare
Are Transformers Effective for Time Series Forecasting?| Pit filling
Is log4j vulnerability still widespread?
Exception -exception
[question 21] idiom Solitaire (Beijing Institute of Technology / Beijing University of Technology / programming methods and practice / primary school)
Alibaba Senior Software Testing Engineer recommends testers to learn -- Introduction to security testing
Huaneng Fujian company and Huawei digital energy deepen strategic cooperation and jointly build a low-carbon smart county
JVM garbage collection garbage collector and common combination parameters
[numerical analysis exercise] Jacobi iteration method of third-order matrix
Log4j vulnerability is still widespread and continues to cause impact
项目分析(哪些是it培训给不了)
vs2019 release模式调试:此表达式有副作用,将不予计算。
Credit default prediction based on simplified scorecard, smote sampling and random forest
项目分析(从技术到项目、产品)
固体继电器
Deploy dolphin scheduler high availability cluster based on rainbow