I want open certain links in a new tab. Since I can't set it directly into the a tag, I want to pot the link into span tags with a ceratin class name and set the target attribute via javascript.
I thought this would be easy, but I can't get it working:
addOnloadHook(function () {
document.getElementByClassName('newTab').getElementsByTagName('a').setAttribute('target', '_blank');
});
<span class="newTab"><a href="http://www.com">Link</a></span>
What am I doing wrong?