piffy

localstorage

Aug 6th, 2021
807
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="it">
  3. <head>
  4. </head>
  5. <body>
  6. <h1>Demo di localstorage</h1>
  7. <textarea id="area" rows="10" cols="80"></textarea>
  8. <p></p>
  9. <button onclick="salva()">Salva</button>
  10. <button onclick="carica()">Carica</button>
  11. <script>
  12.   function salva() {
  13.     var contenuto = document.getElementById("area").value;
  14.     localStorage.setItem("contenuto", contenuto);
  15.   }
  16.   function carica() {
  17.     var contenuto = localStorage.getItem("contenuto");
  18.     document.getElementById("area").value = contenuto;
  19.   }
  20. </script>
  21. </body>
  22. </html>
RAW Paste Data