[英]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.