Horje

Learn HTML sessionStorage Object

The following example counts the number of times a user has clicked a button, in the current session:
index.html
Example: HTML
<script>
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.";
</script>

Output should be:

Learn HTML sessionStorage Object




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Web Storage API
Uploaded by:
Admin