How to change the target of any local link when clicked, using javascript / jquery?
<p>I need to change the href of any local link when it is clicked on.
I've worked out how to select the correct links and create the new url, but not sure how to change the location. I need to be certain that any other click events have also run, so I can't just change the location immediately.</p>

<pre><code>var my_host = 'example.com';
$(document).click(function(e) {
    if(e.target.hostname == my_host)
    {
        alert(e.target.protocol + "//" + e.target.hostname + "/#" + e.target.pathname + e.target.search);
        //...
    }
});
</code></pre>

<p>This is related to my <a href="http://stackoverflow.com/questions/3970649/how-to-select-all-local-links-in-jquery">earlier question</a>.</p>
