1/* 2 external.js - standards-compliant way of opening new-window links 3 $Id: external.js,v 1.1 2004/11/16 22:27:49 ashaffer Exp $ 4 $Revision: 1.1 $ 5 From http://www.sitepoint.com/article/standards-compliant-world/3 6*/ 7(function() { 8 function externalLinks() { 9 if (!document.getElementsByTagName) return; 10 var anchors = document.getElementsByTagName("a"); 11 for (var i=0; i<anchors.length; i++) { 12 var anchor = anchors[i]; 13 if (anchor.getAttribute("href") && 14 (anchor.getAttribute("rel") != null) && 15 (anchor.getAttribute("rel").indexOf("external") !== -1)) { 16 anchor.target = "_blank"; 17 } 18 } 19 var forms = document.getElementsByTagName("form"); 20 for(var i = 0; i<forms.length; i++) { 21 var form = forms[i]; 22 /* Abuse of the class attribute. */ 23 if(form.getAttribute("class") == "external") { 24 form.target = "_blank"; 25 } 26 } 27 } 28 29 var exchainonload = window.onload; 30 window.onload = function() {externalLinks(); if(exchainonload) exchainonload();} 31})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.