title: Use JavaScript to intercept all document link clicks
body: <p>How do I intercept link clicks in document?
  It must be cross-platform.</p>
  <p>I am looking for something like this:</p>
  <pre><code>// content is a div with innerHTML
  var content = document.getElementById(&quot;ControlPanelContent&quot;);
  
  content.addEventListener(&quot;click&quot;, ContentClick, false);
  
   function ContentClick(event) {
   
      if(event.href == &quot;http://oldurl&quot;)
    {
       event.href = &quot;http://newurl&quot;;
    }
  } 
  </code></pre>