I am using a simple Jquery script to force target="_blank" on all external links. The problem is that it opens up subdomains in new windows. I want to adapt this code so it allows for subdomains in the same browser session versus forcing a new window.
For instance, if my site was on http://pixeltest.com and I had a link to http://test.pixeltest.com, that would open up in a new window.
The Code:
$("a").filter(function() {
return this.hostname && this.hostname !== location.hostname;
}).attr('target', '_blank');
Any thoughts on how I can do this?
change
to
this should only then compare everything after the first dot.