Skip to content

Instantly share code, notes, and snippets.

@Fannon
Last active July 5, 2017 12:04
Show Gist options
  • Save Fannon/2190ad83f997d8dcbd0576a74ede41c0 to your computer and use it in GitHub Desktop.
Save Fannon/2190ad83f997d8dcbd0576a74ede41c0 to your computer and use it in GitHub Desktop.
make all links open in new tab
function convertLinks() {
console.log('convertLinks()');
var links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++){
links[i].setAttribute('target', '_blank');
}
}
convertLinks();
// window.onload = convertLinks;
// element.addEventListener('DOMNodeInserted', convertLinks, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment