我试图将xsl变量值传递给javascript函数.
我的xsl变量
<xsl:variable name="title" select="TITLE" />
Run Code Online (Sandbox Code Playgroud)
我正在传递这样的价值
<input type="button" value="view" onclick="javascript:openPage('review.html?review=$title')" />
Run Code Online (Sandbox Code Playgroud)
我以不同的方式尝试了上面的代码,但我得到了错误.
<script type="text/javascript">
function jsV() {
var jsVar = '<xsl:value-of select="TITLE"/>';
return jsVar;
}
</script>
<input type="button" value="view" onclick="javascript:openPage('javascript:jsV()')" />
I also tried
<input type="button" value="view" onclick="javascript:openPage('review.html?review='\''
+$title+'\')" />
Run Code Online (Sandbox Code Playgroud)
有替代方式还是我做得不对?
您忘记了 {}:
<input type="button" value="view" onclick="javascript:openPage('review.html?review={$title}')" />
Run Code Online (Sandbox Code Playgroud)