This is just a quick share, but while developing my site, I realized I don’t want visitors to click on a link and be taken away from my site. The proper way to do this is to add the target=”_blank” to all your external links like so.
<a href="http://www.deltatangobravo.com" target="_blank">design</a>
But I’m way too busy to remember to do that for every link I add to my blog. I mean I try to but what happens when I forget. So I wrote a small jQuery snippet to get my back.
$("a:not([href^='http://www.dinnermint.org']):not([href^='#']):not([href^='/'])").attr("target","_blank");
It looks for all links on my page that do not begin with my domain www.dinnermint.org and adds the attribute target=”_blank”. Laziness FTW!