Question 1: What Is Windows.LocalStorage?
Answer: 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 user' browsers. local storage same as cookies,session in web application.
Local Storage Without affecting web application performance. Local Storage is more secure. It can store large amount of data.(10MB). Local Storage can store one page can access web application All pages. Each And Every domain its own local storage variable.
- To Set Local Store in web application than 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: