you want to use document.getElementById("theidgoeshere");
To do this, set the id attribute in your link like so:
Google
Then in your javascript
var anchor = document.getElementById("theidgoeshere");
if(anchor.getAttribute("href"))
anchor.target = "_blank";
Also note you might want to do without the javascript. Just put target="_blank"
in your anchor tag.