Skip to content

Instantly share code, notes, and snippets.

@fike
Forked from azone/open-in-blank.js
Last active August 29, 2015 14:01
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 fike/1f75e3a673b14183a2f2 to your computer and use it in GitHub Desktop.
Save fike/1f75e3a673b14183a2f2 to your computer and use it in GitHub Desktop.
function addBlankTargetForLinks () {
$('a[href^="http"]'||'a[href^="https"]').each(function(){
$(this).attr('target', '_blank');
});
}
$(document).bind('DOMNodeInserted', function(event) {
addBlankTargetForLinks();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment