Skip to content

Instantly share code, notes, and snippets.

@Eruant
Created October 12, 2012 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eruant/3878620 to your computer and use it in GitHub Desktop.
Save Eruant/3878620 to your computer and use it in GitHub Desktop.
Load external links in new window / tab
function set_external_links() {
$('a[href^=http]').not('a[href^="'+window.location.protocol+'//'+window.location.host+'"]').click(function(e){
e = window.event || e; if(e.preventDefault) e.preventDefault(); else e.returnValue = false;
window.open(this.href); return false;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment