Javascript examples for DOM HTML Element:Anchor
Open links in another window by setting the <a> target attribute
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload = function(e) {/*from www. j a v a2 s .c o m*/ var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { links[i].target = '_blank'; } } </script> </head> <body> <a href="http://www.example.com/">Link 1</a> <a href="http://www.example.com/">Link 2</a> <a href="http://www.example.com/">Link 3</a> </body> </html>