Developer forum

Forum » Templates » open external navigation link in new window

open external navigation link in new window

Jesper Friis
Reply
Hi
I can't figure out how to make an external navigation link open in a new window. Is it some code I need to add to the <a> tag in LIClean.xslt?
-Jesper


Replies

 
Sten Hougaard
Reply
 Hi Jesper,

There are many ways in which you can do this, here is one way:

  <xsl:template match="//Page">
    <xsl:param name="depth"/>
    <li>
      <a>
        <xsl:if test="contains(@Href, 'http://')">
          <xsl:attribute name="target">_blank</xsl:attribute>
        </xsl:if>
The thing which does the job is the xsl:if which tests if the Href attribute of the current Page element contains "http://". If it does that the link is probertly not a local link, but an external link. It then sets an attribute "target" on the link (a) tag.

Hope this helps.

/Sten
 
Jesper Friis
Reply
super
working great
cheers jesper

 

You must be logged in to post in the forum