Skip to content

Instantly share code, notes, and snippets.

@adamstac
Created March 22, 2012 15:16
Show Gist options
  • Save adamstac/2158949 to your computer and use it in GitHub Desktop.
Save adamstac/2158949 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
// Open external links in a new window
hostname = window.location.hostname
$("a[href^=http]")
.not("a[href*='" + hostname + "']")
.addClass('link external')
.attr('target', '_blank');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment