title: How to differentiate browser close and refresh using angularjs?
body: <p>I have localstorage for employeeid stored.When i refresh the browser get local storage value like employeeid based on employeeid get some data .when i close the browser i want to clear employeeid in local storage by using angularjs or javascript. I tried the following code.</p>
  
  <pre><code>window.onunload = close;
      function close() {
          //// do something...
          localStorage.clear();
          return null;
      }
  </code></pre>
  
  <p>In the above code when i refresh the browser that time also window.onunload fired and clear the local storage values, but i want to clear local storage at the time of browser close only.</p>