Is there a way to open all <a href> links on a page in new windows?

If you have a page consisting of only links, consider <base target="_blank">. This opens every link in a new window (but also includes the targets of forms, unless overridden with <form target="_self">.

As others have shown, without modifying the HTML source, you can use Javascript to iterate through all <a> tags and add the target attribute or add an event listener that sets the target attribute dynamically.


If you have jQuery it's simple

$("a").attr("target", "_blank");

Or regular Javascript

var links = document.links;
for (var i = 0; i < links.length; i++) {
     links[i].target = "_blank";
}

As per @Lekensteyn's suggestion, without Javascript (added for Completeness)

<base target="_blank">.