What is HTML5 Web Storage

In this article I have described the Web Storage in HTML5
  • 1835

INTRODUCTION

HTML 5 web storage, the most common method for storing data locally on a user's machine was to use cookies and sessions. HTML 5 web storage allows a developer the freedom to store large amounts of data on the clients machine unencrypted data to be transmitted to the server and stored items are available on the entire domain.

Browser Support

Browser Support
Internet Explorer v8+ Yes
FireFox v3.5+ Yes
Google Chrome v4+ Yes
Safari v4+ Yes
Opera v10.5+ Yes

Note: Internet Explorer 7 and earlier versions, do not support web storage.


// Yes!  local Storage support!
local Storage - stores data with no expiration date.

Example of web storage

<!DOCTYPE html>
<html>
<head>
<script>
function Add()
{
             f(typeof(Storage)!=="undefined")
            {
                      if (localStorage.Add)
                      {
                                localStorage.Add=Number(localStorage.Add)+10;
                       }
                      else
                       {
                                localStorage.Add=10;
                        }
                       document.getElementById("result").innerHTML="clicked the button 10 Add: " + localStorage.Add + " time(s).";
             }
             else
             {
                          document.getElementById("result").innerHTML="Sorry, your browser does not support web storage.....";
              }
}
</script>
</head>
<body>
<p><button onclick="Add()" type="button">Add</button></p>
<div id="result"></div>
<p>To see the Sum:</p>
<p>Close the browser tab, and try again, and the Sum will continue:</p>
</body>
</html>

OUTPUT
web storege.jpg
Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2019 DotNetHeaven. All rights reserved.