jQuery: How to Open External Links in New Window

Example 1:

$('a').click( function() {
	if( this.hostname && this.hostname !== location.hostname ) {
		window.open( $(this).attr('href') );
		return false;
	}
});

This first example just opens the link in a new window any time the link is to an external domain.

Example 2:

var h = window.location.host.toLowerCase();
$("a[href^='http']:not([href^='http://" + h + "']):not([href^='http://www." + h + "']):not([href^='https://" + h + "']):not([href^='https://www." + h + "']):not([href^='mailto']), a[href$='.pdf']").attr("target", "_blank").append(' »');

This next example opens the link in a new window if the href attribute points to an external domain, but is not a mailto: link or a link to a PDF document.

BitTorrent Sync

BitTorrent, creators of the file-sharing protocol by the same name, have announced the release of their new app, BitTorrent Sync. Sync allows the secure, encrypted transfer of files between multiple clients using the BitTorrent protocol.