Developer forum

Forum » Templates » xslt & javascript

xslt & javascript


Reply
Hi there i have this problem about a simple menu in xslt
 
i want everytime i click on it a new window to be open here is the peace of code how i am doing that :

<a onclick="window.open('{@FriendlyHref}',menubar=1,resizable=1,width=350,height=250);return false;">
          <xsl:attribute name="href">javascript:void(0);
          </xsl:attribute>
          <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>
        </a>
but i doesnot work on firefox any idea on what i am doing wrong??

thanks in advance

Replies

 
Nicolai Høeg Pedersen
Reply
Because of your "return false" on the onclick...

You should use one of these combinations:
href="#" onclick="window.open(..."
OR
href="javascript:window.open(..."
 
Reply

I tried both of this combination but still not working on firefox and i think the problem has to do with javascript:void(0); !!!

 
Reply
Hi Stravos,

I used this code to correct the href's when the FriendlyHref came with javascript:window.open. Maybe you can get something to work with.

<a>
  <xsl:choose>
    <xsl:when test="substring(@FriendlyHref,1,10)='javascript'">
      <xsl:attribute name="href">#</xsl:attribute>
      <xsl:attribute name="onClick"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
    </xsl:when>
    <xsl:otherwise>
      <xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
    </xsl:otherwise>
  </xslchoose>
</a>

Best Regards,
Nuno
 
Nicolai Høeg Pedersen
Reply
Stavros - your problem is the "return false" after your window.open....
 
Reply
Thanks !!

for the replay nicolai you were right! but for a reason the page was cashed and i couldn't see the results!!

 

You must be logged in to post in the forum