What Is Windows.LocalStorage?
The Local storage mechanism spans multiple windows and persists beyond the current session. The Local Storage attribute provides persistent storage areas for domains. It allows Web applications to store nearly 10 MB of user data. Web Application Can Store Data Locally in users' browsers. local storage the same as cookies, sessions in web applications.
Local Storage Without affecting web application performance. Local Storage is more secure. It can store large amounts of data.(10MB). Local Storage can store one page that can access web application All pages. Each And Every domain its own local storage variable.
- To Set Local Store in web application then you can use below syntax,
Syntax: Windows.localStorage.setItem(Variable,value);
- To get Local Storage value,
Syntax: Windows.localStorage.getItem(Variable,);
- To Remove Value in Local Storage Variable,
Syntax: Windows.localStorage.removeItem(Variable,);
Example:
- <html>
- <script type="text/javascipt">
- windows.onload = setValue; function setValue(){ windows.localStorage.setItem("UserName","Kamal Bhagat") } function onClick(){ document.getElementById("txtUserName").text = windows.localStorage.getItem("UserName") }
- </script>
- <body>
- Username:
- <input type="text" id="txtUserName">
- <br>
- <input type="submit" value="click" onclick="setValue();">
- </body>
- </html>
More Information About Below Link You can See: