title: Local storage add item
body: <p>I am trying to build a little web app using local storage.  I can add and delete items . I want to add new item to local storage but I always fail.  When i try to add a new item it always show "no localStorage in window".</p>
  
  <p><strong>So I edit it (still not works)</strong> : </p>
  
  <pre><code>function addStorage() {
      var key = document.getElementById('storageKey');
      var data = document.getElementById('storageData');
      var nic = document.getElementById('storageNic');
  
  
      //localStorage setItem
      if ("localStorage" in window) {
          localStorage.setItem(key.value, data.value, nic.value);
          location.reload();
      } else {
          alert("no localStorage in window");
      }
  
  
  function removeStorage() {
      var key = document.getElementById('removeKey');
  
      //localStorage removeItem
      if ("localStorage" in window) {
          if (localStorage.length &gt; 0) {
              localStorage.removeItem(key.value);
              location.reload();
          }
      } else {
          alert("no localStorage in window");
      }
  
  
  }
  
  function clearStorage() {
      //localStorage clear
      if ("localStorage" in window) {
          if (localStorage.length &gt; 0) {
              localStorage.clear();
              location.reload();
          }
      } else {
          alert("no localStorage in window");
      }
  
  
  }
  
  
  window.onload = function () {
      var localhtml = "";
  
      //localStorage key and getItembr
      for (var i = 0; i &lt; localStorage.length; i++) {
          localhtml += "&lt;li&gt;" + localStorage.key(i) + " " + localStorage.getItem(localStorage.key(i)) + "&lt;/li&gt;";
      }
      document.getElementById('localStorageData').innerHTML = localhtml;
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;script&gt;
  function addTextTag(text){
      document.getElementById('storageKey').value += text;
     } 
  &lt;/script&gt;
  &lt;input type="text" id="storageKey"&gt;
  &lt;input type="text" id="storageData"&gt;
  &lt;input type="text" id="storageNic"&gt;
  &lt;input type="button" id="save" value="SAVE" onclick="addStorage();return false;"&gt;
  &lt;input type="button" id="clear" value="Clear" onclick="clearStorage(); return false;"&gt;
  &lt;div id="localStorageData"&gt;&lt;/div&gt;
  </code></pre>