Re: External Links on Xaraya.com

andyv <[email protected]> Mon, 20 Sep 2004 03:05:03 +0100
Newsgroups gmane.comp.cms.xaraya.curiosa
Organization xaraya
Message-ID <[email protected]>
David Dyess II wrote:
> I'm curious as to how the external links work on Xaraya.com.  I know it 
> uses rel="external" in the links and I know it uses the js:
> 
> setExternalLinks=function() {
>     if ( !document.getElementsByTagName ) {
>         return null;
>     }
> 
>     var anchors = document.getElementsByTagName( "a" );
>     for ( var i = 0; i < anchors.length; i++ ) {
>         var anchor = anchors[i];
>         if ( anchor.getAttribute( "href" ) && anchor.getAttribute( "rel" 
> ) == "external" ) {
>             anchor.setAttribute( "target", "_blank" );
>         }
>     }
> }
> 
> 
> What am I missing?   :/

We use this javascript method to alter the links with attribute 
rel="external" by adding target attribute, so they can
- be XHTML Strict compliant (no target in markup)
- openable in new window (which is a job of JS rather than HTML)
- styleable differently from normal (internal) links

That's all to it.
AndyV
p.s. you're probably missing the way the attachEvent and 
addEventListener are used at the end of the script ;-)