How to user Window localStorage Property?
Create a localStorage name/value pair with name="website" and value="htmlcssdownload.com", then retrieve the value of "website" and insert it into the element with id="result":
<!DOCTYPE html>
<html>
<head>
<title>How to use window localStorage property? - HtmlcssDownload.com</title>
</head>
<body>
<div id="result"></div>
<script type="text/javascript">
// Store
localStorage.setItem("website", "htmlcssdownload.com");
// Retrieve
document.getElementById("result").innerHTML = localStorage.getItem("website");
</script>
</body>
</html>
Definition and Usage
The localStorage and sessionStorage properties allow to save key/value pairs in a web browser.
The localStorage object stores data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year.
The localStorage property is read-only.
We are Recommending you:
How to preview link with iframe and javascript?
Sunday 10th of January 2021 05:58:27 PM
javascript
How to add class and remove class in javascript?
Thursday 7th of January 2021 03:35:21 PM
Javascript