<!DOCTYPE html>
<html>
<body>
<div id="result"></div>
<script>
if (typeof(Storage) !== "undefined") {
if (localStorage.pagecount) {
localStorage.pagecount = Number(localStorage.pagecount)+1;
} else {
localStorage.pagecount = 1;
}
document.getElementById("result").innerHTML = "You have visited this page " + localStorage.pagecount + " time(s).";
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
</script>
<p>Refresh the page to see the counter increase.</p>
<p>Close the browser window, and try again, and the counter will continue.</p>
</body>
</html>