<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Comments on snippet: 'Automatically use jQuery to Open External Links in New Window (checking domain first)'</title>
<link>http://snipplr.com</link>
<description>Snipplr comments feed'</description>
<language>en-us</language>
<pubDate>Thu, 20 Jun 2013 03:51:34 GMT</pubDate>
<item>
<title>UnseenRevolution said on 7/27/11</title>
<link>http://snipplr.com/view/50715/automatically-use-jquery-to-open-external-links-in-new-window-checking-domain-first/</link>
<description><![CDATA[ I like to use the following for external links:  

`$(function() {  
    $('a:not([href=""])').each(function() {  
        if (this.hostname !== location.hostname) {  
            $(this).addClass('externalLink').attr('target', "_blank");  
        }  
    });  
 });  `

  
It gives me the ability to insure that the links are actually external and also allows me to add a class the the external links for styling. For example adding an external link icon.  

Full code can be found at:  
[jQuery External Links ](http://www.unseenrevolution.com/2011/06/25/external-links-with-jquery/ "Title") ]]></description>
<pubDate>Wed, 27 Jul 2011 05:39:41 GMT</pubDate>
<guid>http://snipplr.com/view/50715/automatically-use-jquery-to-open-external-links-in-new-window-checking-domain-first/</guid>
</item>
</channel>
</rss>