Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

target="_blank" in XHTML 1.0 Strict

I've always wondered how to add a target="_blank" to my XHTML 1.0 Strict pages. Thanks to this article, I now know a nice workaround.

Much to the chagrin of Web designers everywhere, the HTML 4.0 Strict and XHTML 1.0 Strict recommendations of the W3C no longer include the target attribute of the <a> tag. The Transitional versions of the specifications still include it, but by definition, these specs are on the way out.

The short and sweet version is to use the "rel" attribute to your advantage.

<a href="document.html" rel="external">external link</a>

And then use this short script to key off this attribute for adding a target="_blank" (using the DOM).

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")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;


Throw this in an "external.js" file and add it to whatever pages you need it in.

<script type="text/javascript" src="/external.js"></script>

This LOT more work than I expected, but since it's written up in an actual article, I tend to believe that this is probably the shortest path to making this happen.

Posted in The Web at May 04 2003, 06:13:06 AM MDT 1 Comment
Comments:

Thank you so much for this! I have been searching for a legal way to accomplish this, and every method I found did not satisfy me. This is GREAT. Thanks.

Posted by AJ Lincoln on January 04, 2004 at 08:10 PM MST #

Post a Comment:
  • HTML Syntax: Allowed