簡體   English   中英

在xsl中調用具有某些參數的javascript函數

[英]Calling a javascript function in xsl having some argument

我是xsl的新手,我想調用函數podInfo(<agr>),參數是我在xsl中捕獲的xml doc的某些屬性值。 但是函數調用不合適,任何人都可以建議我是對的。 以下是代碼段

<xsl:variable name="xx" select="@name"/>
<td>
   <a href="#" onclick="podInfo(<xsl:value-of select="$xx"/>)">
       <xsl:value-of select="@name"/>
   </a>
</td>

您需要使用<xsl:attribute>元素,這將使您可以輕松構成onclick ,即使用諸如<xsl:value-of> 之類的元素。 這是關於此元素的XSLT2規范

就像這樣:

<a href="#">
  <!-- xsl:attribute means that instead of putting it's result
       into output document, they will be placed as an attributes
       value of parent element (<a> in this case) -->
  <xsl:attribute name="onclick">
     podInfo(<xsl:value-of select="$xx"/>)
  </xsl:attribute>
  <xsl:value-of select="@name"/>
</a>

有關其他示例,請參見此答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM