我尝试了以下代码:
<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
time({$xx});
</script>
我的意图是通过 time() 中的 document.write() 显示文本。但它没有给出任何结果。
我尝试了以下代码:
<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
time({$xx});
</script>
我的意图是通过 time() 中的 document.write() 显示文本。但它没有给出任何结果。
花括号用于“属性值模板”,但在这种情况下,您不是在此处创建属性,而只是一个普通的文本节点。我认为你需要做这样的事情
<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
time(<xsl:value-of select="$xx" />);
</script>
上面的代码片段应该有一个小的更正。参数应在单个引号内传递。
<xsl:variable name="xx" select="'40967.6424503935'"/>
<script type="text/javascript">
time('<xsl:value-of select="$xx" />');
</script>
这将起作用。