当前位置:网站首页>Browser local storage
Browser local storage
2022-06-29 06:10:00 【I will try to be strong】
brief introduction
This article mainly introduces the browser's local storage
Concept :
- The local storage of the browser means that the browser side passes window.sessionStorage and window.localStorage Property to store locally in the browser .
- General storage 5M Left and right data .
To put it bluntly, there are eight api Use .
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> Browser local storage </title>
</head>
<body>
<script> // use first sessionStorage object . // increase , Parameter is key value window.sessionStorage.setItem("name","yehaocong"); // obtain var name = window.sessionStorage.getItem("name"); console.log("name=",name); // Change window.sessionStorage.setItem("name","liaoxiaoyan"); // Delete var name = window.sessionStorage.getItem("name"); console.log("name=",name); window.sessionStorage.removeItem("name"); var name = window.sessionStorage.getItem("name"); console.log("name=",name); // Empty window.sessionStorage.clear() // The second is localStorage,api It's exactly the same // increase , Parameter is key value window.localStorage.setItem("name","yehaocong"); // obtain var name = window.localStorage.getItem("name"); console.log("name=",name); // Change window.localStorage.setItem("name","liaoxiaoyan"); // Delete var name = window.localStorage.getItem("name"); console.log("name=",name); window.localStorage.removeItem("name"); var name = window.localStorage.getItem("name"); console.log("name=",name); // Empty window.localStorage.clear() </script>
</body>
</html>
effect :
The local storage of the browser can be seen in the developer tool .
First, comment out the deleted and emptied code in the above code :
sessionStorage and localStorage Is the difference between the ,sessionStorage Will disappear after the window is closed and reopened , and localStorage Is saved on disk , Only manual deletion will disappear , If the acquired storage is key non-existent , Returns the null.
边栏推荐
- 2022.02.14
- Why Houdini made the pyside2 plug-in crash
- Leetcode theme [array] -219- duplicate Element II exists
- 2022 recommended prefabricated construction industry research report industry development prospect market analysis white paper (the attachment is a link to the network disk, and the report is continuo
- Rich material libraries make modeling easy and efficient for developers
- After nine years of testing, the salary for interviewing Huawei is 10000. Huawei employees: the company doesn't have such a low salary position
- Ctrip launched the "3+2" office mode. Are you sour?
- Multiline regular expression search in Visual Studio code - multiline regular expression search in Visual Studio code
- Problems with MySQL database query
- QT precautions and RCC download address
猜你喜欢

Test Development - ten years of sharpening one sword (VII) interface test tool postman

Sum of digits under k-ary representation of leetcode simple problem

HTTP Caching Protocol practice

Sourcetree remote red exclamation point

The fresh student who was born in Ali after 2000: it's really fragrant to mend this
![ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience](/img/fd/4c24e10fc91a7ce7e709a0874ba675.jpg)
ASP. Net core 6 framework unveiling example demonstration [03]:dapr initial experience

Hustoj SPJ example

Why Houdini made the pyside2 plug-in crash
![[high concurrency] deeply analyze the callable interface](/img/fb/89ebd5592f1383c8015a47cec78a59.jpg)
[high concurrency] deeply analyze the callable interface

JS messagechannel transport
随机推荐
Multiline regular expression search in Visual Studio code - multiline regular expression search in Visual Studio code
證券開戶安全麼,有沒有什麼危險呢
5,10,15,20-tetra (3,5-dimethoxyphenyl) porphyrin ((tdmpp) H2) /2-nitro-5,10,15,20-tetra (3,5-dimethoxyphenyl) porphyrin copper (no2tdmpp) Cu) supplied by Qiyue
Rearrangement string of leetcode simple question
RTOS embarqués
What are the uses of static?
Servlet version conflict causes page 404
Plugin
Slot
Mongodb basic knowledge summary
3 frequently tested SQL data analysis questions (including data and code)
2022 community group buying industry research industry development planning prospect investment market analysis report (the attachment is the online disk link, and the report is continuously updated)
Difference between static and final
2022 recommended RCEP regional comprehensive economic partnership agreement market quotation Investment Analysis Industry Research Report (the attachment is a link to the online disk, and the report i
Stack -- 739 Daily temperature
Go compile source code (window environment)
Awk of shell script
Common methods for describing 3D models of objects and their advantages and disadvantages
What is MES? What does it do?
Loosely matched jest A value in tohavebeencalledwith - loose match one value in jest toHaveBeenCalledWith