We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

donnies38 on 07/24/07


Tagged

valid window new


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

iTony
wizard04


Standards Compliant Open in new Window


Published in: JavaScript 


  1. function doStandardsCompliantExternalLinks() {
  2. if (!document.getElementsByTagName) {return;}
  3. var anchors = document.getElementsByTagName("a");
  4. for (var i=0; i<anchors.length; i++) {
  5. if (anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external") {// for example: title="Download Adobe Reader" rel="external"
  6. anchors[i].target = "_blank";
  7. anchors[i].title += " - Opens in new window";
  8. }
  9. }
  10. }

Report this snippet 

You need to login to post a comment.