Reputation: 23
This is a chrome extension that prints a list of links. My code looks like this
function main(linkArray) {
for (var i = 0; i < linkArray.length; i++) {
document.write(linkArray[i].link(linkArray[i]) + "\n");
}
}
main(["example.com", "example2.com", "example3.com"]);
When the links are printed, if I click on them, nothing happens, but if I scroll-click (to open a new tab) they work fine. How do I make it so that if I left-click them, they open in a new tab?
Upvotes: 2
Views: 42
Reputation: 37701
You can use the target
attribute to denote where the links open (with a regular click), for example:
<a href="example.com" target="_blank">link</a>
will open example.com in a new tab/window.
Since your code definitely doesn't provide links, I can't write you how to implement it exactly, but you should set target="_blank"
on your anchors.
Upvotes: 2