Posted By

kyokutyo on 02/20/08


Tagged

link window external


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

heinz1959


external link


 / Published in: JavaScript
 

add onclick="window.open(this.href); return false;" to a Tag with rel="external"

  1. function externalLinks() {
  2. if (! document.getElementsByTagName ) return;
  3. var anchors = document.getElementsByTagName("a");
  4. var isIE = (document.documentElement.getAttribute("style") == document.documentElement.style);
  5. for (var i=0; i<anchors.length; i++) {
  6. if(anchors[i].getAttribute("href") && anchors[i].getAttribute("rel") == "external"){
  7. if(isIE) anchors[i].setAttribute("onclick",new Function("window.open(this.href); return false;"));
  8. else anchors[i].setAttribute("onclick","window.open(this.href); return false;");
  9. }
  10. }
  11. }
  12.  
  13. window.onload = externalLinks;

Report this snippet  

You need to login to post a comment.