title: How can I with javascript hide my sidenav when pressing back on my andriod?
body: <p>I wonder if I can somehow close my sidenav in my html page when pressing the back button on android or in a browser.</p>
  
  <pre><code>function openSlideMenu(){
      document.getElementById('side-bar').style.width = "256px";
  }
  function closeSlideMenu(){
      document.getElementById('side-bar').style.width = "0px";
  }
  </code></pre>
  
  <p>I've got this javascript so when I press a button it opens and closes my sidenav together with my stylesheet.</p>
  
  <p>(I think it is good to mention that I'm pretty new with javascript.)</p>
  
  <p>EDIT: I've googled a ton and found that with <code>window.onhashchange</code> together with <code>newURL</code> and <code>oldURL</code> you're able to manipulate a browsers history to make it work.</p>
  
  <p>Maybe it's better to use <code>pushState</code> and <code>popState</code>.</p>