如何将 xsl 变量值传递给 javascript 函数 [英] how to pass a xsl variable value to a javascript function

查看:36
本文介绍了如何将 xsl 变量值传递给 javascript 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个 xsl 变量值传递给一个 javascript 函数.

i am trying to pass an xsl variable value to a javascript function.

我的 xsl 变量

<xsl:variable name="title" select="TITLE" />

我像这样传递值

<input type="button" value="view" onclick="javascript:openPage('review.html?review=$title')" />

我以不同的可能方式尝试了上述代码,但出现错误.

i have tried the above code in different possible ways but i gets errors.

<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+'\')" />

是否有其他方法或我做得不对?

Is there alternative way or am i not doing it right?

推荐答案

你忘记了 {}:

<input type="button" value="view" onclick="javascript:openPage('review.html?review={$title}')" />

这篇关于如何将 xsl 变量值传递给 javascript 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆