0

Can I define something in HTML to set all of my hyperlink targets to "_blank"?

I'm in a Web Tech course and I have to use a bunch of hyperlinks, and it gets aggravating because sometimes I forget to add target="_blank" so it redirects me out of my assignment when I test. I'm using Adobe Dreamweaver as my editor, if that makes any difference

27th Sep 2017, 2:11 PM
Brandon Shaw
Brandon Shaw - avatar
1 Réponse
+ 4
No, but with JavaScript you can do this: function setToBlank(){ for (var i = 0; i < document.links.length; i++){ document.links[i].setAttribute('target', '_blank'); } } This code sets the targets for each links to blank.
27th Sep 2017, 3:30 PM
David
David - avatar