title: Javascript code to preventDefault for all <a href> links
body: <p>I am trying to get URLs to change using only Javascript, by updating the content via AJAX.</p>
  
  <p>This is to prevent certain content (namely music, chat message boxes, etc) from refreshing and either </p>
  
  <ol>
  <li>Clearing the place where your music is playing</li>
  <li>Resetting something you are working on, like typing a message.</li>
  </ol>
  
  <p>I just began today trying to implement something like this, and so far I've got this:</p>
  
  <pre><code>var a = document.querySelectorAll('a')
  for (var i=0; i&lt;a.length; i++) {
     a[i].addEventListener('click',function(event){event.preventDefault();};
  }
  return false
  </code></pre>
  
  <p>However, this code</p>
  
  <ol>
  <li>Doesn't allow the url to be changed</li>
  <li>Doesn't load the AJAX.</li>
  </ol>
  
  <p>My question is: how do I cancel the age from refreshing, but still allow the url to change?</p>