“Better” Standards-based Replacement for target="_blank" in External Links

The JavaScript on this page does pretty much the same thing as in the previous one. The difference is that this code keys off the href value in the links instead of requiring a class attribute. The CSS does the same to insert the silly little door icons.

As before, the JavaScript is completely separable from the content here on this page. You could place it in an external file and then, just by adding a script tag to a document, modify the behavior of all external links on that page.

« Back to my workshop