External links script from SitePoint not working

Hi, I searched the forum for other posts about this, but none of them seemed to contain info to solve my problem. My site pages are now html4/strict so I used the “function externalLinks” script found here http://articles.sitepoint.com/print/standards-compliant-world. I followed the instructions carefully, made sure I copied the script shown to the external.js file and uploaded it into the same directory as the html files. Also made sure that external.js was called as required in the head. Also made sure all target=“_blank” were changed to rel=“external” as required. Unfortunately, it doesn’t work. The link takes the visitor outside my site, instead of creating a new window. I don’t get it. Here’s one of my pages …
http://www.keithpurtell.com/kthings/bj-cole.htm

Your script isn’t quite the same as the code in that article:

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;

ralph.m -
I’m not exactly sure how I mangled the original script, but your anchor.target = “_blank”; makes my new-window links work perfectly!!

Heh heh, great. But it’s not mine, as such. I just copied it directly from the article. :slight_smile: