title: How to detect URL changes in SPA
body: <h2>Note</h2>
  
  <p>Solution should be in pure Javascript - No external library and frameworks.   </p>
  
  <hr>
  
  <p>In SPA, Everything gets routed using routing mechanism.
  I just want to listen to an even whenever any part of url changes (Not only hash. Any change I want to detect)</p>
  
  <p>Following is example of SPA,</p>
  
  <pre><code>https://www.google.in/
  https://www.google.in/women 
  https://www.google.in/girl 
  </code></pre>
  
  <p>Now whenever url changes from <a href="https://www.hopscotch.in/" rel="noreferrer">https://www.hopscotch.in/</a> to <a href="https://www.hopscotch.in/women" rel="noreferrer">https://www.hopscotch.in/women</a>, I want to capture that event.</p>
  
  <p>I tried,</p>
  
  <pre><code>window.addEventListener("hashchange",function(event){
      console.log(this); // this gets fired only when hash changes
  });
  </code></pre>