Press "Enter" to skip to content

HTML5-Session Storage Example

Last updated on October 5, 2019

Definition :

     Session storage hold the data still the end of user session storage.

Program :

<html>

   <script>

     a=1;

                   function display()

                   {

                    if(typeof(Storage)!=”undefined”) {

                                if(sessionStorage.clickCount) {

                                sessionStorage.clickCount=Number(sessionStorage.clickcount)+1;

                                } else {

                                sessionStorage.clickcount=1;

                                }

                                document.getElementById(“result”).innerHTML=you have clicked the button”+sessionStorage.clickCount+”time(s) in this session.”;

                                } else {

                                document.getElementById(“result”).innerHTML=”sorry, your browser does not support web storage…”;

                                }

                                }

                                </script>

                                <body>

                                  <button onClick=”display()”> click me </button>

                                  <div id=”result”> </div>

                                </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *