gpt4 book ai didi

javascript - 将 XSL 参数传递给 JS

转载 作者:行者123 更新时间:2023-11-30 06:46:14 25 4
gpt4 key购买 nike

我尝试将参数传递给 XSL 文件中的 javascript...我该怎么做?

    <xsl:variable name="currentPath">
<xsl:value-of select="concat($path, ./name)"/>/
</xsl:variable>

<script>
someFunction(someParameter);
</script>

由于布局原因,我会在这里再次尝试:

<script>  document.getElementById('<xsl:value-of select="$currentPath"></xsl:value-of>').style.display = 'none'; 
</script>

我正在使用一个变量,它是模板中的一个参数

<xsl:template match="dir">  
<xsl:param name="path"/>

变量用作表的id:

<table border="0" id="$currentPath"> 

这个变量在其他地方使用,并且在那里工作......顺便说一句,我在 Firefox 3.5.xx 上

另一个编辑:我把

<xsl:value-of select="$currentPath"/>

就在脚本标签之前,结果是预期的......变量不是问题......

最佳答案

在表格元素的引用周围使用花括号:

<table border="0" id="{$currentPath}">

关于javascript - 将 XSL 参数传递给 JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6492276/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com