How to match external links with javascript (but ignore subdomains)?
<p>I have the following (jquery) selector looking for external links.</p>

<p>This works, and ignores all links that include <code>location.hostname</code> <em>(e.g. www.domain.com)</em></p>

<p>My question is, how to extend this to also ignore links to subdomains of your site? <em>(e.g. new.domain.com)</em></p>

<pre><code>$('a').each(function() {

    var href = $(this).attr('href');

    if(this.hostname &amp;&amp; this.hostname !== location.hostname) 
    {    
        $(this)
            .removeAttr('target')
            .attr('rel', 'external')                
            .attr('title', href)
            .click(function() {
                window.open($(this).attr('href'));
                return false;
            });
        }
});
</code></pre>
