Your Ad Here

Posted By

shamrog12 on 07/09/06


Tagged


Versions (?)

Who likes this?

7 people have marked this snippet as a favorite

luman
xaviaracil
mate
meth
shamrog12
kgosser
guo3823538


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.