Skip to content

Instantly share code, notes, and snippets.

@drench
Created September 14, 2010 20:42
Show Gist options
  • Save drench/579738 to your computer and use it in GitHub Desktop.
Save drench/579738 to your computer and use it in GitHub Desktop.
soderbergs target=_blank code
/* one way: */
for (var i=0,L; L=document.links[i]; ++i) {
if (L.title.match(/\b(Join\s+Our\s+Mailing\s+List|Shop\s+Online)\b/i)) {
L.setAttribute('target', '_blank');
}
}
/* another way, maybe a bit more readable: */
for (var i=0,L; L=document.links[i]; ++i) {
if (
(L.title == 'Join Our Mailing List') ||
(L.title == 'Shop Online')
)
{
L.setAttribute('target', '_blank');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment