How can I save HTML locally with JavaScript?

JavascriptWeb DevelopmentFront End Technology

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>
      <p id="visits"></p>
         var visits = parseInt(document.cookie.split("=")[1]);
         if (isNaN(visits)) visits = 0;
         document.cookie = "visits =" + visits;
         document.getElementById("visits").innerHTML = "The page ran " + timesVisited + " times.";

Just save the above file and open in a web browser.

Updated on 15-Jun-2020 13:14:54