I'm making a script which, automatically ads target="_blank" to all external links. The problem is that, the script also makes the internal absolute links open in a new tab. You can check the problem on this test link: http://www.fairfood.org/testtest/
$("a").filter(function () { return this.hostname && this.hostname !== location.hostname; }).each(function () { $(this).attr({ target: "_blank", title: "Visit " + this.href + " (click to open in a new window)" }); }); Does anybody know how to fix this?
Any help is much appreciated.
TWTR is not definedandFB is not defined. Might want to fix those first.www.fairfood.org!=fairfood.orghostnamehere. also, I believe this object is treated differently in other browsers so simply using thenotselector w/ your domain name should work.