JavaScript: open links in new tabs
<p>I would like to make a JavaScript that would put in each link the attribute <code>target="_blank"</code>, so that the link would open in a new tab. This is how I did it:</p>

<pre><code>function open_links_in_new_tabs() {
    var links = document.documentElement.getElementsByTagName( "a" );
    for(var link in links) {
        link.setAttribute("target", "_blank");
    }
}

window.onload = function() { open_links_in_new_tabs(); }
</code></pre>

<p>But, this doesn't work. Do you see where the mistake is?</p>

<p>Thanks,</p>

<p>Ivan</p>
