将Java变量传递给javascript函数 [英] Passing a java variable to a javascript function
本文介绍了将Java变量传递给javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下一段代码,是js库的输入内容:
I have the following piece of code which is a input content for a js lib:
content:'<a href="x.com" onclick="confirmDel("<%=user.name%>")" > <img src="delete.png" alt="Delete" width="15px" height="15px"></a></div>'
confirmDel(name)
{
if(confirm("delete " + name +" ?"))
{
// Do delete stuff
} else
{
return false;
}
}
当我单击删除链接时,它不会提示我删除确认警报!我在这里想念什么?这与我将变量传递给函数的方式有关吗?
when I click the delete link, it does not prompt me with the delete confirmation alert! what am I missing here? Is it about the way I pass the variable to the function?
推荐答案
content:'<a href="x.com" onclick="confirmDel(\''+<%=user.name%>+'\')" > <img src="delete.png" alt="Delete" width="15px" height="15px"></a></div>'
在onclick中使用传递参数的问题.使用转义符.
problem with passing parameter in the onclick..use escape character..
这篇关于将Java变量传递给javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文