LINUX.ORG.RU

История изменений

Исправление static_lab, (текущая версия) :

Решение без сервера вообще:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <input id="value">
  <script>
    const input = document.getElementById('value');
    const storage = window.localStorage;

    input.value = storage.getItem('value');

    input.addEventListener('input', e => {
      storage.setItem('value', e.target.value);
    });

    window.addEventListener('storage', () => {
      input.value = storage.getItem('value');
    });
  </script>
</body>
</html>

Исходная версия static_lab, :

Решение без сервера вообще:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <input id="value">
  <script>
    const input = document.getElementById('value');
    const storage = window.localStorage;

    input.value = storage.getItem('value');

    input.addEventListener('input', e => {
      storage.setItem('value', e.target.value);
    });

    window.addEventListener('storage', () => {
      console.log(storage.getItem('value'));
      input.value = storage.getItem('value');
    });
  </script>
</body>
</html>