File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <script>
5
+ function clickCounter() {
6
+ if (typeof(Storage) !== "undefined") {
7
+ if (sessionStorage.clickcount) {
8
+ sessionStorage.clickcount = Number(sessionStorage.clickcount)+1;
9
+ } else {
10
+ sessionStorage.clickcount = 1;
11
+ }
12
+ document.getElementById("result").innerHTML = "You have clicked the button " + sessionStorage.clickcount + " time(s) in this session.";
13
+ } else {
14
+ document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
15
+ }
16
+ }
17
+ </script>
18
+ </head>
19
+ <body>
20
+
21
+ <p><button onclick="clickCounter()" type="button">Click me!</button></p>
22
+ <div id="result"></div>
23
+ <p>Click the button to see the counter increase.</p>
You can’t perform that action at this time.
0 commit comments