We have to dynamically set the attribute target="_blank" and it will open it in new tab.
document.getElementsByTagName("a")[0].setAttribute('target', '_blank')
document.getElementsByTagName("a")[0].click()
If you want to open in new window, get the href link and use window.open
var link = document.getElementsByTagName("a")[0].getAttribute("href");
window.open(url, "","height=500,width=500");
Don't provide the second parameter as _blank in the above.