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>
<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.

raja
Published on 24-Jan-2018 06:14:50
Advertisements