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.