/ Published in: JavaScript
Expand |
Embed | Plain Text
<script type="text/javascript"> function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName('a'); for each (anchor in anchors) { if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external') { anchor.target = '_blank'; } } } window.onload = externalLinks; </script>
Comments
Subscribe to comments
You need to login to post a comment.

Again: the "_blank" attribute through the JavaScript backdoor. Better (?) include onclick="window.open(this.href); return false;" inside the a href. This is longer, but XHTML and DOM compliant.