XSLT Add target = "_ blank" to the url

I created an XSLT file that goes through a SharePoint list to create a resource table. One part of it creates a link that leaves the site. I want to open it in a new window with target = "_ blank", but I'm not sure how to do this in XSLT.

Here is the part that creates the link:

<xsl:element name="a">
    <xsl:attribute name="href">
        <xsl:value-of select="Website"/>
    </xsl:attribute>
    <xsl:text>Visit Website</xsl:text>
</xsl:element>

Can anyone shed some light on this for me? I am new to XSLT.

+5
source share
2 answers

Will this work?

<xsl:element name="a">
<xsl:attribute name="href">
    <xsl:value-of select="Website"/>
</xsl:attribute>
   <xsl:attribute name="target">_blank</xsl:attribute>
<xsl:text>Visit Website</xsl:text>
</xsl:element>
+8
source

This is actually much simpler: you do not need these xsl: element and xsl: attribute instructions in general. Just do

<a href="{Website}" target="_blank">Visit Website</a>

XSLT , !

+5

All Articles