title: Open all external links open in a new tab apart from a domain
body: <p>I'm trying to open all external links on a site in a new window. However on there are 2 versions of the site, e.g. a store and the main site. So on the main site we might have links that go to <a href="http://store.example.com" rel="noreferrer">http://store.example.com</a> for example.</p>
  
  <p>I've got some code here which will allow me to open all the external links in a new window. However I'd like to be able to exclude certain domains. Like the one I've mentioned above.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>$(document).ready(function() {
     $("a[href^=http]").each(function(){
        if(this.href.indexOf(location.hostname) == -1) {
           $(this).attr({
              target: "_blank",
              title: "Opens in a new window"
           });
        }
     })
  });
  </code></pre>
  
  <p>I'm new to JS / jQuery so any additional information would be brilliant.</p>