Target=_blank: Deprecated. Won't validate.

Shop for web design and development books here.

Here’s another one the validator will reject: target="_blank". The only way (that I’ve found) around it is to use a little Javascript in the head section. I found this on the web, somewhere:

<script type="text/javascript">
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external") = "_blank";
 window.onload = externalLinks;

…and then use rel='external' in links, when opening a new browser window is desired.

Leave a Reply

Your email address will not be published. Required fields are marked *