To save HTML locally with JavaScript, create an HTML file and save the following code in it. The code is for cookies in JavaScript −
<!DOCTYPE html>
<html>
<body>
<p id="visits"></p>
<script>
var visits = parseInt(document.cookie.split("=")[1]);
if (isNaN(visits)) visits = 0;
visits++;
document.cookie = "visits =" + visits;
document.getElementById("visits").innerHTML = "The page ran " + timesVisited + " times.";
</script>
</body>
</html>Just save the above file and open in a web browser.