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

shamrog12 on 07/09/06


Tagged


Versions (?)


Who likes this?

6 people have marked this snippet as a favorite

luman
xaviaracil
mate
meth
shamrog12
kgosser


rel="blank"


Published in: JavaScript 


Javascript Open Page in New Window Using rel="blank." Put this function in the . To create a link that open in a new page use

  1. <!--
  2. function externalLinks() {
  3. if (!document.getElementsByTagName) return;
  4. var anchors = document.getElementsByTagName("a");
  5. for (var i=0; i<anchors.length; i++) {
  6. var anchor = anchors[i];
  7. if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "blank") {
  8. anchor.target = "_blank";
  9. }
  10. }
  11. }
  12. window.onload = externalLinks;
  13. //-->

Report this snippet 

Comments

RSS Icon Subscribe to comments
Posted By: doublej on August 29, 2008

Why use this in stead of the target attribute?

You need to login to post a comment.