Skip to content

Instantly share code, notes, and snippets.

@wagnerpinheiro
Forked from azone/open-in-blank.js
Last active August 29, 2015 13:57
Show Gist options
  • Save wagnerpinheiro/9392929 to your computer and use it in GitHub Desktop.
Save wagnerpinheiro/9392929 to your computer and use it in GitHub Desktop.
//open links with '#_blank' anchor in a new page
function addBlankTargetForLinks () {
$('a[href^="http"],a[href*="#_blank"]').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