targetsheet

Summary

Style hyperlink elements with window targetting behavior based on their semantic 'rel' and sub-semantic 'class' attributes.

For more documentation and details, please see: http://tantek.com/log/targetsheetdoc.html

Code


/////////////////////////////////////////////////////////////////
var undefined;
var gebi = document.getElementById != undefined;
for (var i=0;i!=document.links.length;i++) { 
 var L=document.links[i];
 var c=L.className; 
   // determine if link is a permalink
 var perm = (L.rel.indexOf('bookmark')!=-1);
   // if link is explicitly classed to local or has same path as document, no target
 if (c.indexOf('local')!=-1 || L.pathname==document.location.pathname) { } 
 else if (c.indexOf('photo')!=-1) {L.target='z';}  // photos get the photo target
 else if (!perm) if (c.indexOf('plink')==-1) {L.target='lockon';} // externals get a target
   // decorate '#' permalinks with little mini-angle-bracket-like things
   // could use generated content instead
 if (gebi) if (perm) if (L.innerText=='#') { L.innerHTML='‹#›';}
 // Valentine's Day mods:                  { L.innerHTML='♥'; L.style.color='red';}
}
/////////////////////////////////////////////////////////////////