Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Cristian 24 posts 45 karma points
    Nov 24, 2011 @ 17:45
    Cristian
    0

    concat javascript instruction with apostrophe in xslt

    hi all

    i have a problem i trying to concat a  link reference in xslt:

    this is my code:

    <xsl:element name="a" >
                <xsl:attribute name="class">metaNavItem noDecoration</xsl:attribute>
                <xsl:if test="./@newwindow = '1'">
                  <xsl:attribute name="target">_blank</xsl:attribute>
                </xsl:if>
                
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:value-of select="concat('JavaScript:newPopup(',./@link,');')" />
                      <!--<xsl:value-of select="./@link"/>-->
                    </xsl:attribute>
                   </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="./@title"/>
              </xsl:element>

    that i want when type is external get the string in href attribute:

    JavaScript:newPopup('http://mypage.com');

    so my question is how can i set the apostrophe in concat function, i allready try with &apos; code

    regards.

  • Cristian 24 posts 45 karma points
    Nov 24, 2011 @ 18:23
    Cristian
    0

    well i find the solution for this problem, i dont use the concant() function i replace thad code with this:

      <xsl:text>JavaScript:newPopup('</xsl:text>
      <xsl:value-of select="./@link"/>
      <xsl:text>');</xsl:text>

    now my problem is: the link open a new blank window....donĀ“t open the window with the url,

    if i put the link directly in my html code works perfectly, so what i have to do? some configuration or property missing?

     

  • Cristian 24 posts 45 karma points
    Nov 24, 2011 @ 18:27
    Cristian
    0

    my mistake!!!! daem!!

    just delete attribute target....

    code:

              <xsl:element name="a" >
                <xsl:attribute name="class">metaNavItem noDecoration</xsl:attribute>
                <xsl:choose>
                  <xsl:when test="./@type = 'external'">
                    <xsl:attribute name="href">
                      <xsl:text>JavaScript:newPopup('</xsl:text>
                      <xsl:value-of select="./@link"/>
                      <xsl:text>');</xsl:text>
                    </xsl:attribute>
                   </xsl:when>
                  <xsl:otherwise>
                    <xsl:attribute name="href">
                      <xsl:value-of select="umbraco.library:NiceUrl(./@link)"/>
                    </xsl:attribute>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="./@title"/>
              </xsl:element>

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Nov 24, 2011 @ 21:51
    Chriztian Steinmeier
    0

    Hi Cristian,

    Heres a more readable way of doing the same thing:

    <a class="metaNavItem noDecoration" href="{umbraco.library:NiceUrl(@link)}">
        <xsl:if test="@type = 'external'">
            <xsl:attribute name="href">
                <xsl:text>javascript:newPopup('</xsl:text>
                <xsl:value-of select="@link" />
                <xsl:text>')</xsl:text>
            </xsl:attribute>
        </xsl:if>
        <xsl:value-of select="@title" />
    </a>

    Since an element can not have duplicate attributes, the href attribute will just be overridden when necessary.

    /Chriztian

  • Cristian 24 posts 45 karma points
    Nov 24, 2011 @ 23:52
    Cristian
    0

    ohh thanks Chiztian for you reply,

    and yes its more redable. thanks!!!

     

Please Sign in or register to post replies

Write your reply to:

Draft